How to Retrieve Values of A Dynamically Created Control's Child Controls on PostBack?
- by Jordan
Given: I have a custom server control in the markup of an aspx page. This control creates child controls in its CreateChildControls() method (e.g. it retrieves content from a database and based on that content dynamically creates either a CheckBoxList or a RadioButtonList)
Now I understand that I cannot access the dynamically created controls on postback unless I add them again on Page_Init or Page_PreInit (as per here).
My question is, how do I add them again explicitly in Page_Init or Page_PreInit if they are just going to be added yet again when we get around to calling Render() on each of the custom server controls?
I'm very certain this is not a unique problem, so there must be a best practice way of doing it...I just don't know what it is :/