我有一个返回排序列表的方法,我想将其数据源到下拉列表。
我在用
DropDownList1.DataSource=stList;
DropDownList1.DataValueField=stList.ContainsValue();
DropDownList1.DataTextField=stList.ContainsKey();
DropDownList1.DataBind();
但它给出了一个错误:没有 containsKey 和 containsValue 的重载方法。
如何在下拉列表中填充这个排序表?
DropDownList1.DataSource = stList;
DropDownList1.DataValueField = "Key";
DropDownList1.DataTextField = "Value";
DropDownList1.DataBind();
[Edit]
添加经过测试的工作代码:
SortedList<int, string> list = new SortedList<int, string>();
list.Add(1, "Test1");
list.Add(2, "Test2");
dropDownList.DataTextField = "Value";
dropDownList.DataValueField = "Key";
dropDownList.DataSource = list;
dropDownList.DataBind();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)