如何邦定DropDownList1 SqlCommand DBRS = new SqlCommand("Select Trname from Tradmin", conn); SqlDataReader DB = DBRS.ExecuteReader();DropDownList的id: DropDownList1字段 Trname 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DropDownList1.DataSource=DBDropDownList1.DataTextField=Trname;DropDownList1.DataValueField=TrID;DropDownList1.DataBind();不过数据库源最好是DaTaTable,DataReader转换成Table就行了。 vs2005中无需代码,直接拉控件过来用,然后他会提示让你选择数据源。或者你在Design视图中选中你的DropDownList控件然后右击选择“smart tag”会出现一个菜单页面让你配置DropDownList的数据源。 ListItem li = new ListItem(Trname,TrID);this.DropDownList1.Items.Add(li); TrID 是什么? 不是很明白? SqlCommand DBRS = new SqlCommand("Select Trname from Tradmin", conn); SqlDataReader DB = DBRS.ExecuteReader();字段 Trname DropDownList的id: DropDownList1DropDownList1.DataSource=DBDropDownList1.DataTextField="Trname"; 你的字段 呈现的DropDownList1.DataValueField="Trname";你的字段 隐藏的DropDownList1.DataBind(); 请教一个问题,winform怎么内嵌一个可以自定义格式的报表 Page.Request.Files.Count问题! 水晶报表判断问题很简单,来者有分。 如何获取局域网共享文件版本号? asp.net调试技巧,谢谢大家哦 如何让这个数组依次输出 来 Winform下算吧,有含金量的题,解了却感觉怪怪的.评评,或许有更高效的 无限长度数字的四则运算 asp.net中正则表达式的含义 谁有在C#下做类似于officexp菜单和按钮的控件(最好不是com组件,最好是.net组件), 使用带参数的SQL语句, 如何使其支持 IN (@parm) 这样的格式 关于页面之间传递值得问题。。大家请指点
DropDownList1.DataTextField=Trname;
DropDownList1.DataValueField=TrID;
DropDownList1.DataBind();
不过数据库源最好是DaTaTable,DataReader转换成Table就行了。
或者你在Design视图中选中你的DropDownList控件然后右击选择“smart tag”会出现一个菜单页面让你配置DropDownList的数据源。
this.DropDownList1.Items.Add(li);
是什么?
不是很明白?
SqlDataReader DB = DBRS.ExecuteReader();
字段 Trname
DropDownList的id: DropDownList1
DropDownList1.DataSource=DB
DropDownList1.DataTextField="Trname"; 你的字段 呈现的
DropDownList1.DataValueField="Trname";你的字段 隐藏的
DropDownList1.DataBind();