Creating Quiz with 100 Question in single page. Successfully created radio button list DYNAMICALLY. But now problem is how to retrieve the Data stored in radio button list.
For reference code pasted to create radio button list dynamically
protected void Page_Load(object sender, EventArgs e)
{
int n = 100;
for (int i = 0; i < n; i++)
{
RBLPlaceHolder.Controls.Add(new RadioButtonList());
}
IterateThroughChildren(this);
}
void IterateThroughChildren(Control parent)
{
foreach (Control c in parent.Controls)
{
if (c.GetType().ToString().Equals("System.Web.UI.WebControls.RadioButtonList") &&
c.ID == null)
{
((RadioButtonList)c).Items.Add("A");
((RadioButtonList)c).Items.Add("B");
((RadioButtonList)c).Items.Add("C");
((RadioButtonList)c).Items.Add("D");
((RadioButtonList)c).RepeatDirection = RepeatDirection.Horizontal;
count++;
}
if (c.Controls.Count > 0)
{
IterateThroughChildren(c);
}
}
}