public static void BindListControls(System.Web.UI.WebControls.ListControl control, System.Data.DataTable dataSource) { control.DataSource = dataSource; control.DataTextField = "Text"; control.DataValueField = "Value"; control.DataBind(); }
public void PopulateList(System.Web.UI.WebControls.ListControl list) { for (int i = 0; i < _RowCount; i++) { list.Items.Add(new System.Web.UI.WebControls.ListItem(_NameCol[i].ToString(), _IDCol[i].ToString())); } }
/// <summary> /// ListControl extension method to bind it with Enum type /// </summary> /// <typeparam name="TEnum">Target Enum Type</typeparam> /// <param name="ddl">The DDL.</param> /// <remarks></remarks> public static void BindByEnum <TEnum>(this System.Web.UI.WebControls.ListControl ddl) where TEnum : struct { ddl.DataSource = EnumUtils.GetListItemCollection <TEnum>(); ddl.DataTextField = "Value"; ddl.DataValueField = "Key"; ddl.DataBind(); }
public static void BindList(this System.Web.UI.WebControls.ListControl list, IEnumerable <ReturnOrdersShipmentAddressViewBO> vlcts, string valueField, string textField) { list.DataSource = vlcts; list.DataValueField = valueField; list.DataTextField = textField; list.DataBind(); list.Items.Insert(0, new System.Web.UI.WebControls.ListItem("All", "0")); }
public static void BindListClone(this System.Web.UI.WebControls.ListControl list, IEnumerable <GetNonAssignedPriceMarkupDistributorsViewBO> lstgnapmd, string valueField, string textField) { list.DataSource = lstgnapmd; list.DataValueField = valueField; list.DataTextField = textField; list.DataBind(); list.Items.Insert(0, new System.Web.UI.WebControls.ListItem("Select your new distributor", "0")); }
public static void BindList(this System.Web.UI.WebControls.ListControl list, IEnumerable <ReturnDistributorSecondaryCoordinatorBO> vlcts, string valueField, string textField) { list.DataSource = vlcts; list.DataValueField = valueField; list.DataTextField = textField; list.DataBind(); list.Items.Insert(0, new System.Web.UI.WebControls.ListItem("All", "0")); }
public static void BindList(this System.Web.UI.WebControls.ListControl list, IEnumerable <VisualLayoutCoordinatorsBO> vlcs, string valueField, string textField) { list.DataSource = vlcs; list.DataValueField = valueField; list.DataTextField = textField; list.DataBind(); list.Items.Insert(0, new System.Web.UI.WebControls.ListItem("All", "0")); }
/// <summary> /// 绑定城市 /// </summary> /// <param name="lst"></param> /// <param name="pid"></param> public static void BindCity(System.Web.UI.WebControls.ListControl lst, int pid) { using (DataEntities ent = new DataEntities()) { var cts = (from l in ent.City where l.ProvinceID == pid select l).ToList(); lst.Items.Clear(); foreach (var ct in cts) { lst.Items.Add(new System.Web.UI.WebControls.ListItem(ct.city1, ct.id.ToS())); } } }
/// <summary> /// Loads the list control. /// </summary> /// <param name="ddl">The DDL.</param> /// <param name="type">The type.</param> /// <param name="lang">The lang.</param> /// <remarks></remarks> public void LoadListControl(System.Web.UI.WebControls.ListControl ddl, string type, string lang = "en") { XmlNodeList filter = this.SelectNodes("//" + type + "/Detail[@lang='" + lang + "']"); Dictionary <string, string> myDictionary = new Dictionary <string, string>(); foreach (XmlNode item in filter) { myDictionary.Add(item.Attributes["text"].InnerText, item.Attributes["value"].InnerText); } ddl.DataSource = myDictionary; ddl.DataTextField = "key"; ddl.DataValueField = "value"; ddl.DataBind(); }
public static void BindToEnum(this System.Web.UI.WebControls.ListControl listControl, Type enumType) { var dictionary = new Dictionary <int, string>(); foreach (int value in Enum.GetValues(enumType)) { dictionary.Add(value, Enum.GetName(enumType, value)); } listControl.DataSource = dictionary; listControl.DataTextField = "Value"; listControl.DataValueField = "Key"; listControl.DataBind(); }
/// <summary> /// Adds a <typeparamref name="System.ListItem"/> as the first item in this <typeparamref name="System.Web.UI.WebControls.ListControl"/>'s "Items" collection, with the text value of "- Select -". /// </summary> /// <param name="ctrl"></param> /// <param name="defaultValue">A <typeparamref name="System.String"/> value to assign to the new item. Default is "-1".</param> public static void AddSelectItem(this System.Web.UI.WebControls.ListControl ctrl, string defaultValue = "-1") { ctrl.Items.Insert(0, new System.Web.UI.WebControls.ListItem("- Select -", "-1")); }