[英]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.