如何在asp.net和c#中加载下拉列表?
解决方法
您也可以声明性地执行此操作:
<asp:DropDownList runat="server" ID="yourDDL"> <asp:ListItem Text="Add something" Value="theValue" /> </asp:DropDownList>
您还可以绑定数据:
yourDDL.DataSource = YourIEnumberableObject; yourDDL.DataBind();
编辑:如评论中所述,您还可以以编程方式添加项目:
yourDDL.Items.Add(YourSelectListItem);