List<String> nameList = new List<String>();
DropDownList ddl = new DropDownList();
列表在这里居住,然后进行排序:C# - 倾销名单的下拉列表
nameList.Sort();
现在我需要把它放到下拉列表,这就是我遇到的问题(使用的foreach ):
foreach (string name in nameList){
ddl.Items.Add(new ListItem(nameList[name].ToString()));
}
没有工作 - 任何建议吗?它给我的编译错误:
Error - The best overloaded method match for 'System.Collections.Generic.List<string>.this[int]' has some invalid arguments
Error - Argument '1': cannot convert from 'string' to 'int'