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