其他分享
首页 > 其他分享> > DropDownList 使用记录

DropDownList 使用记录

作者:互联网

原文链接:http://www.cnblogs.com/longhorn008/archive/2005/08/26/223781.html DataSet:

使用DataSource的格式就是这样的.
第一步:设定数据源 ddl.DataSource = dr;
第二步:设置显示的Text字段 ddl.DataTextField = "字段名";
第三步:设置值 ddl.DataValueField = "字段名";
第四步:绑定数据操作 ddl.DataBind();

DataReader:
while(rd.Read())
{
    string temp=rd["name"];
    ddl.Items.Add(temp);
    ddl.Items.FindByText(temp).Value=rd["id"];
}
推荐使用第二种,可定制性更强

转载于:https://www.cnblogs.com/longhorn008/archive/2005/08/26/223781.html

标签:www,temp,记录,ddl,26,rd,使用,archive,DropDownList
来源: https://blog.csdn.net/weixin_30698527/article/details/96982040