日期:2014-05-20  浏览次数:20403 次

DropDownList的绑定
public DataSet table()
  {
  DataSet dbset = new DataSet();
  DbCommand dbCommand = _DB.GetStoredProcCommand("LibEcological_SelectHostelTONum");//存储过程名查的是整张表
  dbset=_DB.ExecuteDataSet(dbCommand);
  dbCommand.Dispose();
  return dbset;
  }

listHostNum.DataSource = ???
listHostNum.DataTextField = ?????
listHostNum.DataValueField =?????
listHostNum.DataBind();


------解决方案--------------------
listHostNum.DataSource = table().Tables[0];
listHostNum.DataTextField = table().Tables[0].Cloumns[0].CloumnName;
listHostNum.DataValueField = table().Tables[0].Cloumns[0].CloumnName;
listHostNum.DataBind();
 
------解决方案--------------------
探讨

引用:
listHostNum.DataSource = table().Tables[0];
listHostNum.DataTextField = table().Tables[0].Cloumns[0].CloumnName;
listHostNum.DataValueField = table().Tables[0].Cloumns[0].Cloumn……

------解决方案--------------------
把dataset 换成datatable再用他们的方法吧,
------解决方案--------------------
HTML code

<asp:DropDownList ID="DropDownList1" runat="server" DataTextField="Name" 
                DataValueField="Id">其中DataTextField为显示的值
            </asp:DropDownList>