checkboxes
我正在尝试在我的asp.net
项目中添加两组。我正在这样做:
在页面加载时:
public static CheckBox[] chck = new CheckBox[100];
public static CheckBox[] chckbx = new CheckBox[100];
我有一个功能:
public void generatecheckbox1()
{
for (int i = 0; i < 99; i++)
{
chck[i] = new CheckBox();
chck[i].ID = chck + Convert.ToString(i);
chck[i].Text = chck + Convert.ToString(i);
pnlcom1.Controls.Add(chck[i]);
pnlcom1.Controls.Add(new LiteralControl("<br />"));
chckbx[i] = new CheckBox();
chckbx[i].ID = chckbx + Convert.ToString(i);
chckbx[i].Text = chckbx + Convert.ToString(i);
pnlcom2.Controls.Add(chckbx[i]);
pnlcom2.Controls.Add(new LiteralControl("<br />"));
}
}
我在这里调用这个函数:
protected void ddluserwebser_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddluserwebser.SelectedItem.Text == "Custom")
{
generatecheckbox1();
}
}
问题是我收到这样的错误页面:
它是这么说的:
Multiple controls with the same ID 'System.Web.UI.WebControls.CheckBox[]0' were found. FindControl requires that controls have unique IDs.
但是我分配了不同ids..
的我应该怎么做?