所以我正在创建一个DropDownList。这是我在Page_Load方法中的codebehind文件中的代码。
我在aspx文件中有一个Content标签,DropdownList应该在里面此内容标记。目前,没有专家组或
DropDownList显示。有什么遗漏吗?
所以最后它应该直接从代码隐藏文件添加DDL,而不在aspx文件中写入内容。(+会有代码数据源,但我无法显示它)
public Panel GetDropDownList()
{
// Create drop down list and data source
Panel pnlChannel = new Panel();
DropDownList ddlChannel = new DropDownList();
ListItem limDefault = new ListItem();
SqlDataSource sdsChannel = new SqlDataSource();
// Configure data source
// Configure drop down list
ddlChannel.DataTextField = "Channel";
ddlChannel.DataValueField = "Channel";
ddlChannel.AppendDataBoundItems = true;
ddlChannel.DataSourceID = "sdsChannel";
// Configure default list item
limDefault.Selected = true;
limDefault.Text = "All";
limDefault.Value = "-1";
// Add controls to static panel in footer
ddlChannel.Items.Add(limDefault);
pnlChannel.Controls.Add(ddlChannel);
pnlChannel.Controls.Add(sdsChannel);
return pnlChannel;
}