我有以下代码:
string str = string.Empty;
foreach (ListItem item in this.CheckBoxList1.Items)
{
if (item.Selected)
{
str += item.Value + "<br><br>";
TextBox txt1 = new TextBox();
}
}
lbl1.Text = str;
我想要的是每个检查过的数据我想要一个文本框。当我遍历复选框列表时,标签将获取我的值并显示它们,但不显示文本框。我该怎么办?
答案 0 :(得分:2)
foreach (ListItem item in this.CheckBoxList1.Items)
{
if (item.Selected)
{
str += item.Value + "<br><br>";
TextBox txt1 = new TextBox();
//name of your form should go here
form1.Controls.add(txt1);
//plus you have to figure it out how to position textboxes on the page
}
}