我正在向页面动态添加一个单选按钮列表,在按钮单击时我想存储这些值。但我无法在页面上找到控件。请在下面找到示例代码。
for(int i=1;i<10;i++)
{
Table tblStars = new Table();
RadioButtonList rb = new RadioButtonList();
rb.ID = i.ToString();
----
TableCell tc=new TableCell();
TableRow tr=new TableRow();
tc.Controls.Add(rb);
tr.cells.Add(tc);
tblStars.Rows.Add(tr);
ContentPlaceHolder.Controls.Add(tblStars);
}
在按钮单击事件上,
protected void btnPost_Click(object sender, EventArgs e)
{
for(int i=1;i<10;i++)
{
RadioButtonList rb = (RadioButtonList)this.Page.FindControl(i.ToString());
}
}
在这里,我找不到控件。FindControl 返回 null。
我在这里错过了什么吗?
谢谢