RadioButtonList1 的 DataTextField 如何指定为第几个字段,比如读数据可以dr[0]这样
RadioButtonList1 的 DataTextField 怎么指定为第几个字段,比如读数据可以dr[0]这样
RadioButtonList1 的 DataTextField 怎么指定为第几个字段,比如读数据可以dr[0]这样
如下例,sql语句是动态的,这里也不知道具体的字段是什么,只知道DataTextField为第二个字段,DataValueField为第一个字段
string sql = Request["sql"];
DataTable dt = TSQL.GetDataTable(sql);
RadioButtonList1.DataTextField = "第二个字段(这里根据sql语句里来的)";
RadioButtonList1.DataValueField = "第一个字段(这里根据sql语句里来的)";
RadioButtonList1.DataBind();
这里该怎么实现,没法指定,但是也不能去掉,去掉直接绑定了,也不能显示出数据,全是System.Data.DataRowView
------解决思路----------------------
------解决思路----------------------
like it:
http://www.cnblogs.com/insus/archive/2011/11/17/2252587.html
RadioButtonList1 的 DataTextField 怎么指定为第几个字段,比如读数据可以dr[0]这样
如下例,sql语句是动态的,这里也不知道具体的字段是什么,只知道DataTextField为第二个字段,DataValueField为第一个字段
string sql = Request["sql"];
DataTable dt = TSQL.GetDataTable(sql);
RadioButtonList1.DataTextField = "第二个字段(这里根据sql语句里来的)";
RadioButtonList1.DataValueField = "第一个字段(这里根据sql语句里来的)";
RadioButtonList1.DataBind();
这里该怎么实现,没法指定,但是也不能去掉,去掉直接绑定了,也不能显示出数据,全是System.Data.DataRowView
------解决思路----------------------
string sql = "select * from province";
DataTable dt = SQLHelper.ExecuteDataTable(sql);
this.RadioButtonList1.DataSource = dt;
this.RadioButtonList1.DataTextField = dt.rows[0][0];//DataTable中第一行第一列
this.RadioButtonList1.DataValueField =dt.rows[0][1];//DataTable中第一行第2列
this.RadioButtonList1.DataBind();
------解决思路----------------------
like it:
http://www.cnblogs.com/insus/archive/2011/11/17/2252587.html