首先sql语句取出表中的所有列名已经实现select name from syscolumns where id=(select max(id) from sysobjects where xtype='u' and name='RJProduct') 现在想把所有列明绑定到dropdpwnlst中,问题有一个,就是这个表中的列是不确定的是随时增加的,这个绑定怎么实现?求代码。
调试欢乐多
select name from syscolumns where id=(select max(id) from sysobjects where xtype='u' and name='RJProduct')
红色的部分。绑定你指定是name字段就行了,里面多少个元素你不用考虑的
DataSet ds = XXX("你的SQL语句");
this.DropDownList1.DataSource = ds;
this.DropDownList1.DataTextField = "name";
this.DropDownList1.DataValueField = "name";
this.DropDownList1.DataBind();
就OK啦,你多虑啦
http://www.cnblogs.com/insus/archive/2011/11/08/2241255.html
不过说实话,但愿你没把问题描述错,我真不知道你要绑定所有列干什么,一般都是需要一列下的所有值。