I am adding a list of radiobutton lists dynamically to the page and on button click I want to store the values . But I am unable to find the control on the page. Please find the sample code below.
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);
}
On button click event ,
protected void btnPost_Click(object sender, EventArgs e)
{
for(int i=1;i<10;i++)
{
RadioButtonList rb = (RadioButtonList)this.Page.FindControl(i.ToString());
}
}
Here, I am unable to find the control. FindControl is returning null.
Am I missing something here?
Thank you