DropDownList的数据绑定方式
2010-09-05 02:10
381 查看
第一种: DataSet ds= new DataSet(); ds = cls2.SelectOle(); DropDownList1.DataSource = ds.Tables["My"].DefaultView; DropDownList1.DataTextField = "dep_Name"; DropDownList1.DataValueField = "dep_Id"; DropDownList1.DataBind(); 第二种: DataSet set1= new DataSet(); set1 = cls2.SelectOle(); for (int num1 = 0; num1 < set1.Tables["My"].Rows.Count; num1++) { DropDownList1.Items.Add(set1.Tables["My"].Rows[num1][1].ToString()); } <asp:DropDownList id="DropDownList1" DataValueField="dep_Id" DataTextField="dep_Name" runat="server"></asp:DropDownList>
相关文章推荐
- DropDownList(下拉列表框)绑定数据的方式
- DropDownList绑定数据的几种方式
- DropDownList控件的数据绑定方式
- 数据绑定以及Container.DataItem几种方式与用法分析
- 双向数据绑定的三种方式
- DropDownList控件的使用(数据绑定)
- DropDownList绑定数据时选择数据问题
- 双向数据绑定原理(三种实现方式)
- DropDownList控件的数据绑定
- DropDownList绑定数据
- Silverlight与WCF之间的通信(3)利用net.tcp绑定方式寄宿到到控制台交互数据
- 数据绑定以及Container.DataItem几种方式与使用方法分析
- dropdownlist控件的使用(数据绑定)
- 4种方法把数据绑定到Dropdownlist
- (转).net控件dropdownlist动态绑定数据
- DropDownList 绑定数据后插入0行数据
- 从XML文件中读取数据绑定到DropDownList
- MultiActionController绑定表单数据的两种实现方式
- 数据绑定以及Container.DataItem几种方式与用法分析 [转]
- 数据绑定以及Container.DataItem几种方式与用法分析