【发布时间】:2014-06-18 03:45:34
【问题描述】:
我的控件 (System.Web.UI.UserControl) 中有以下 Page_Load 方法:
protected void Page_Load(object sender, EventArgs e)
{
DropDownList ShowAssumptions = new DropDownList();
List<string> list = new List<string>()
{
"test",
"test2"
};
ShowAssumptions.DataSource = from i in list
select new ListItem()
{
Text = i,
Value = i
};
ShowAssumptions.DataBind();
}
然后,在我的 .aspx 中有这个:
<asp:DropDownList id="ShowAssumptions" runat="server">
</asp:DropDownList>
但是,DropDownList 永远不会被填充。我做错了什么?
【问题讨论】:
标签: c# asp.net drop-down-menu webforms