/// <summary> /// 根据数据字典设置下拉框数据源(包含请选择) /// </summary> /// <param name="ddl"></param> /// <param name="ParentCode"></param> public static void SetDDLByDataDictCodeNULL(DropDownList ddl, string ParentCode, DropDownList ddlTwo = null, DropDownList ddlThree = null, DropDownList ddlFour = null, DropDownList ddlFive = null, DropDownList ddlSix = null) { //ddl.DataSource = new Sys_DataDictBLL().FindWhere(" DataDict_ParentCode='" + ParentCode + "' and DataDict_IsDel !='1'").OrderBy(p => p.DataDict_Sequence); List <Sys_DataDict> DataDictList = new List <Sys_DataDict>(); DataDictList = new Sys_DataDictBLL().GetList(p => p.DataDict_ParentCode == ParentCode && p.DataDict_IsDel == false).OrderBy(p => p.DataDict_Sequence).ToList(); DataDictList.Insert(0, new Sys_DataDict { DataDict_Name = Constant.DrpChoiceName, DataDict_Code = "" }); ddl.DataSource = DataDictList; ddl.DataTextField = "DataDict_Name"; ddl.DataValueField = "DataDict_Code"; ddl.DataBind(); if (ddlTwo != null) { ddlTwo.DataSource = DataDictList; ddlTwo.DataTextField = "DataDict_Name"; ddlTwo.DataValueField = "DataDict_Code"; ddlTwo.DataBind(); } if (ddlThree != null) { ddlThree.DataSource = DataDictList; ddlThree.DataTextField = "DataDict_Name"; ddlThree.DataValueField = "DataDict_Code"; ddlThree.DataBind(); } if (ddlFour != null) { ddlFour.DataSource = DataDictList; ddlFour.DataTextField = "DataDict_Name"; ddlFour.DataValueField = "DataDict_Code"; ddlFour.DataBind(); } if (ddlFive != null) { ddlFive.DataSource = DataDictList; ddlFive.DataTextField = "DataDict_Name"; ddlFive.DataValueField = "DataDict_Code"; ddlFive.DataBind(); } if (ddlSix != null) { ddlSix.DataSource = DataDictList; ddlSix.DataTextField = "DataDict_Name"; ddlSix.DataValueField = "DataDict_Code"; ddlSix.DataBind(); } }
/// <summary> /// 根据数据字典代码获取字典名称 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string GetDataDictNameByCode(string code) { string sRtn = string.Empty; Sys_DataDict dict = new Sys_DataDictBLL().Get(p => p.DataDict_Code == code); if (dict != null) { sRtn = dict.DataDict_Name; } return(sRtn); }
/// <summary> /// 根据数据字典设置下拉框数据源(包含请选择) /// </summary> /// <param name="ddl"></param> /// <param name="ParentCode"></param> public static void SetDDLByDataDictCodeAllNULL(DropDownList ddl, string ParentCode) { //ddl.DataSource = new Sys_DataDictBLL().FindWhere(" DataDict_ParentCode='" + ParentCode + "' and DataDict_IsDel !='1'").OrderBy(p => p.DataDict_Sequence); List <Sys_DataDict> DataDictList = new List <Sys_DataDict>(); DataDictList = new Sys_DataDictBLL().GetList(p => p.DataDict_ParentCode == ParentCode && p.DataDict_IsDel == false).OrderBy(p => p.DataDict_Sequence).ToList(); DataDictList.Insert(0, new Sys_DataDict { DataDict_Name = Constant.DrpAllName, DataDict_Code = "" }); ddl.DataSource = DataDictList; ddl.DataTextField = "DataDict_Name"; ddl.DataValueField = "DataDict_Code"; ddl.DataBind(); }