Hi everyone,
I am trying to find out how I can save the data captured in dynamically created controls.
So what happens is on the form load I will load dynamic controls:
switch ("WhichControl")
{
case "ddl":
DropDownList ddl = new DropDownList();
ddl.ID = string.Format("ddList{0}", icounter);
ddl.DataSource = myDataSource();
ddl.DataTextField = "TextField";
ddl.DataValueField = "DataField";
ddl.ClientIDMode = System.Web.UI.ClientIDMode.Static;
ddl.DataBind();
row.Cells[1].Controls.Add(ddl);
break;
case "rb":
RadioButtonList rb = new RadioButtonList();
rb.DataSource = myDataSource();
rb.DataTextField = "TextField";
rb.DataValueField = "DataField";
rb.ID = string.Format("rList{0}", icounter);
rb.ClientIDMode = System.Web.UI.ClientIDMode.Static;
row.Cells[1].Controls.Add(rb);
break;
case "tb":
TextBox tb = new TextBox();
tb.TextMode = TextBoxMode.SingleLine;
tb.ID = string.Format("textBox{0}", icounter);
tb.ClientIDMode = System.Web.UI.ClientIDMode.Static;
row.Cells[1].Controls.Add(tb);
break;
default:
break;
}
now my question is how best can i read the options selected by the user and save it to the database.
An example would be greatly appreciated. When I try to loop through the page I can't get the controls.
Thanks,