关于DropdownList 增加选项内容问题
各位大侠,请教如下问题:我想将SQL 数据库中 ASPABB 这张表中的ABB002这列的内容添加到DropDownList 控件中:请问如何复值
string strcon=ConfigurationSettings.AppSettings ["sqlconn"];
SqlConnection conn = new SqlConnection(strcon );
conn.Open();
SqlCommand comm = new SqlCommand( "select ABB001,ABB002 from ASPABB"
,conn );//===================数据库表查询==========
SqlDataAdapter SDA = new SqlDataAdapter();
SDA.SelectCommand = comm;
DataSet DS = new DataSet();
SDA.Fill(DS);
DropDownList1.datasource=?
DropDownList1.dataBin(); --------------------编程问答-------------------- 不知道表达清楚了没哟,也就是将 SqlCommand comm = new SqlCommand( "select ABB001,ABB002 from ASPABB",conn ) 中查询的ABB002字段内容添加到DropDownList1中就可以了. --------------------编程问答-------------------- DropDownList1.DataSource = DS;
DropDownList1.DataBind();
DropDownList1.DisplayMember = "ABBOO1"; //显示内容所在的字段
DropDownList1.ValueMember = "ABBOO2"; //值所在的字段 --------------------编程问答-------------------- .droplist1.datasourse=ds.table["AB002"] --------------------编程问答-------------------- 谢谢,找到方法了:
DripDownList.DataValueField = "ABB002";
DripDownList.DataSource = ds;
DripDownList.DataBind(); --------------------编程问答-------------------- droplist1.datasourse=ds.tableS["AB002"]这个实现不了,添加不上内容;
DropDownList1.DataSource = DS;
DropDownList1.DataBind();
DropDownList1.DisplayMember = "ABBOO1"; //显示内容所在的字段
DropDownList1.ValueMember = "ABBOO2"; //值所在的字段
没找到DisplayMember, ValueMember这两个属性;
--------------------编程问答-------------------- DropDownList1.DataTextField="ABB001";
DropDownList1.DataValueField = "ABB002";
DropDownList1.DataSource = ds;
DropDownList1.DataBind(); --------------------编程问答-------------------- SqlCommand comm = new SqlCommand( "select ABB001,ABB002 from ASPABB",conn ) 中查询的ABB002字段内容添加到数组ArrayList如何解决?. --------------------编程问答--------------------
取数据到了dataset中,然后循环去读吧。用arraylist.add的方法
补充:.NET技术 , ASP.NET