如果没有html扩展帮助方法,如何创建复选框列表?

时间:2014-01-30 10:32:40

标签: c# html code-behind checkboxlist

我正在尝试创建一个复选框列表,以便用户可以检查列表中的多个项目(这在搜索页面上用作过滤器选项)。

列表框有html帮助方法,下拉列表,多选表单等。如何在C#中创建复选框列表?

1 个答案:

答案 0 :(得分:0)

var oListBox = new ListBox() { ID = "ID", TabIndex = 10 };
oListBox.Items.Add(new ListItem() { Text = "your text", Value = "your value" });
oListBox.Items.Add(new ListItem() { Text = "your text", Value = "your value" });

.... other items if you want ....

Page.Controls.Add(oListBox);