[英]dynamic textbox in c#
我有以下代码:
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;
我想要的是为每个要检查的数据提供一个文本框。 当我遍历“列表”复选框时,标签将使用我的值并显示它们,但文本框不显示。 我该怎么做?
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
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.