ddl的绑定问题 怎么把Dictionary<key,value>绑定到下拉菜单ddl谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DictionaryEntry de = new DictionaryEntry(); de.Key = "111"; de.Value = "111"; DropDownList ddl = new DropDownList(); ddl.Items.Add(new ListItem(de.Value.ToString(), de.Key.ToString())); 貌似不能直接绑定,你可以循环Dictionary 键值,然后加到table或者加进类数组也可 参考: protected void Button1_Click(object sender, EventArgs e) { DropDownList1.DataTextField = "value"; DropDownList1.DataValueField = "key"; DropDownList1.DataSource = GetTypeList(); DropDownList1.DataBind(); DropDownList1.Items.Insert(0, new ListItem("请选择")); } protected Dictionary<int, string> GetTypeList() { Dictionary<int, string> list = new Dictionary<int, string>(); list.Add(1, "one"); list.Add(2, "two"); list.Add(3, "three"); list.Add(4, "four"); return list; } 如何跨域取得XML数据?jsonp,iframe我都搞不定,关键它也不回发数据, 寻求药品差比价使用说明 C#中怎么实现想土豆那样的视频 关于存储过程的一个奇怪的问题 页面布局问题 命名空间的菜问题 我在aspx.vb中写了一段判断代码,如果正确就要包含另一个页面#include...如何写?在线等 急!急!!!!我编写了这样一个程序,运行出现了如下错误提示,哪位帮我?????? Asp.net中的页面字符集问题(高手请进) 请问怎样通过aspx页取物理硬盘序列号? 关于两个dictionary A与B,设A=B,当变动A时,B也会受影响,如何处理? SQL高手们帮小弟看看,先谢了!
de.Key = "111";
de.Value = "111";
DropDownList ddl = new DropDownList();
ddl.Items.Add(new ListItem(de.Value.ToString(), de.Key.ToString()));
{
DropDownList1.DataTextField = "value";
DropDownList1.DataValueField = "key";
DropDownList1.DataSource = GetTypeList();
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, new ListItem("请选择"));
} protected Dictionary<int, string> GetTypeList()
{
Dictionary<int, string> list = new Dictionary<int, string>();
list.Add(1, "one");
list.Add(2, "two");
list.Add(3, "three");
list.Add(4, "four");
return list;
}