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();
[解决办法]
<asp:DropDownList ID="DropDownList1" runat="server" DataTextField="Name" DataValueField="Id">其中DataTextField为显示的值 </asp:DropDownList>