3、DataTextField属性:用于指定DataSource中的一个字段,该字段的值对应于列表项的Text属性。 DropDownList Id=”控件名称” Runat=”Server” AutoPostBack=”True | False” DataSource=”<%数据源%>” DataTextField DataSource = ds.Tables[“tbcalicoinfo”].DefaultView.ToTable(true, “country”);// ToTable去重复 ddl2.DataTextField ddl3.DataSource = ds.Tables[“tbcalicoinfo”].DefaultView.ToTable(true, “ActInstDate”);; ddl3.DataTextField ddl4.DataSource = ds.Tables[“tbcalicoinfo”].DefaultView.ToTable(true, “ResellerName”); ddl4.DataTextField
DropDownList DataTextField DataValueField DataTextField取displayfield字段值 DataValueField取keyfield字段值 6 ListBox DataTextField DataValueField DataTextField取displayfield字段值 DataValueField取keyfield字段值 7 System.Web.UI.HtmlControls HtmlSelect DataTextField DataValueField DataTextField取displayfield字段值 DataValueField取keyfield字段值 实现 System.Web.UI.WebControls.ListBox)_object).DataSource = myDr; ((System.Web.UI.WebControls.ListBox)_object).DataTextField System.Web.UI.HtmlControls.HtmlSelect)_object).DataSource = myDr; ((System.Web.UI.HtmlControls.HtmlSelect)_object).DataTextField
FormView做一个网页,其中用到了DropDownList控件,代码是这样写的: <asp:DropDownList ID=”ddlCategory” DataSourceID=”odsCategory” DataTextField DataValueField的类型必须一致,困扰我好长时间的问题终于解决 正确代码: <asp:DropDownList ID=”ddlCategory” DataSourceID=”odsCategory” DataTextField
web DropDownList绑定数据源的几种方式 第一种 this.ddltype.DataTextField = “btName”;//显示的值 //配置数据源 this.ddl_em.DataSource = list; //绑定字段属性 this.ddl_em.DataTextField
DataSource:为数据源 DataBind:数据源绑定 DataTextField:要显示的文本值 DataValueField:显示文本值的编号 其中DataTextField主要是给用户看的 Department"); DropDownList1.DataSource = DBHelper.Table(sql); DropDownList1.DataTextField
productlist = ProductAdapter .Instance.GetList(); dlproductname.DataSource = productlist; dlproductname.DataTextField //赋值 ArrayList bugtype = EnumHelper.EnumToList(typeof(BugType)); dlzt.DataSource = bugtype; dlzt.DataTextField
CommandType.Text,sql); DropDownList1.DataSource = set.Tables[0]; DropDownList1.DataTextField db.ExecuteDataSet(cmd); DropDownList2.DataSource = set.Tables[0]; DropDownList2.DataTextField db.ExecuteDataSet("Select_Brand"); DropDownList1.DataSource = set.Tables[0]; DropDownList1.DataTextField db.ExecuteDataSet(cmd); DropDownList2.DataSource = set.Tables[0]; DropDownList2.DataTextField
SqlDataReader myreader = mycommand.ExecuteReader() DropDownList1.DataSource = myreader DropDownList1.DataTextField SqlDataReader myreader1 = mycity.ExecuteReader() DropDownList2.DataSource = myreader1 DropDownList2.DataTextField SqlDataReader myreader = mycommand.ExecuteReader() DropDownList2.DataSource = myreader DropDownList2.DataTextField
this.DropDownList1.DataSource = DbHelperSQL.Query(“select * from authors”).Tables[0]; this.DropDownList1.DataTextField System.Web.UI.WebControls.DropDownList)dropDownList).Items.Clear(); ((System.Web.UI.WebControls.DropDownList)dropDownList).DataTextField System.Web.UI.WebControls.DropDownList)dropDownList).Items.Clear(); ((System.Web.UI.WebControls.DropDownList)dropDownList).DataTextField
ds.Tables[0]; DropDownList1.DataValueField = “FoodTypeID”; DropDownList1.DataTextField ds.Tables[0]; DropDownList1.DataValueField = “FoodTypeID”; DropDownList1.DataTextField
SysRoleLogic.GetSysRoleList(); RadComboRole.DataSource = sysRoleList; RadComboRole.DataTextField telerik:RadTreeView ID=”RadTreeView1″ runat=”server” DataSourceID=”SqlDataSource2″ DataTextField
CheckBoxList中有DataTextField和DataValueField可以用于设置绑定时的绑定对象属性,但是可惜针对CheckBoxList却没有办法直接绑定一个Item是否被选中。 接下来的使用方法就很简单了,直接在aspx页面上写该控件的DataCheckedField属性既可: <cc1:CheckBoxListWithCheckBind ID="cbxl" runat="server" DataTextField
该控件继承自DropDownList,在使用中只需要为该控件设置用于数据绑定的DataTextField和DataValueField,以及新增的属性ChildProperty(string,对象的Child ListItem item = new ListItem(); item.Text =GetDeepChar()+ root.GetType().GetProperty(this.DataTextField cc1:DropDownTreeList ID="DropDownTreeList1" runat="server" ChildProperty="ChildArea" DataTextField
: ①添加ddl_Province、ddl_City ②对ddl_Province进行数据绑定 ddl_Province..DataSource = dt; ddl_Province.DataTextField Triggers> </asp:UpdatePanel> ②对ddl_Province进行数据绑定 ddl_Province..DataSource = dt; ddl_Province.DataTextField
DropDownList1.DataSource = dataSet.Tables[“Table1”].DefaultView; //指定DropDownList使用的表里的那些字段 DropDownList1.DataTextField 而且在用DataSet做为数据源的时候,我们要指定: DropDownList1.DataTextField = “ItemName”; //dropdownlist的Text的字段 DropDownList1 DropDownList1.DataSource = dataSet.Tables[“Table1”].DefaultView; //指定DropDownList使用的表里的那些字段 DropDownList1.DataTextField DropDownList1.DataSource = dataSet.Tables[“Table1”].DefaultView; //指定DropDownList使用的表里的那些字段 DropDownList1.DataTextField DataSource = dataSet.Tables[“Table1”].DefaultView; // //指定DropDownList使用的表里的那些字段 // DropDownList1.DataTextField
DropDownList1 添加一个默认选中项 DropDownList1.DataSource = bb.drop(); DropDownList1.DataTextField
EmailType”;
this.DropDownListType.DataSource = xds;
this.DropDownListType.DataTextField
this.ddl_area.DataSource = ds.Tables[“area”].DefaultView; this.ddl_area.DataTextField this.ddl_city.DataSource = ds.Tables[“city”].DefaultView; this.ddl_city.DataTextField this.ddl_city.DataSource = ds.Tables[“city”].DefaultView; this.ddl_city.DataTextField
this.drop.DataSource = db.users.ToList(); //显示的 this.drop.DataTextField
当下拉列表框里的数据需要从数据库里提取的时候,就需要设置DataValueField 和 DataTextField 的属性,每次用的时候都要设置一下,这个比较烦。 (不好意思,我比较懒) 我的方法是在自定义控件的OnInit 时间里面加上 Me.CssClass = "lst" Me.DataValueField = "ID" Me.DataTextField 设置CssClass、DataValueField、DataTextField、" Protected Overrides Sub OnInit(ByVal e As EventArgs) Me.CssClass = "lst" Me.DataValueField = "ID" Me.DataTextField = "txt"