1
我想给我的动态生成的复选框通过一个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/>"));
}
任何帮助的代码是极大的赞赏。
干杯, JAF