[英]dynamic textbox in c#
I have the following code: 我有以下代码:
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;
What I want is for each data checked I want to have a textbox. 我想要的是为每个要检查的数据提供一个文本框。 When I loop through the checkbox List the label takes my values and display them but the textbox not.
当我遍历“列表”复选框时,标签将使用我的值并显示它们,但文本框不显示。 How can I do it?
我该怎么做?
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.