我正在尝试通过 for 循环算法为动态生成的复选框命名。提出算法非常简单,但我无法为他们提供名称/复选框文本。我能想到的最好的办法是为生成的所有内容提供一个类似的复选框文本。有没有办法给它们命名?
下面是我想出的代码
int x = ((((DropDownList1.SelectedIndex+1)*(DropDownList1.SelectedIndex+1))-(DropDownList1.SelectedIndex+1))/2)-1;
Label1.Text = x+"";
for (int i = 0; i < x; i++)
{
CheckBox cb = new CheckBox();
cb.Text = "1 & 2";
PlaceHolder1.Controls.Add(cb);
PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
}
任何帮助是极大的赞赏。
干杯,贾夫