How to Retrieve Values of A Dynamically Created Control's Child Controls on PostBack?
Posted
by
Jordan
on Stack Overflow
See other posts from Stack Overflow
or by Jordan
Published on 2012-03-28T17:27:37Z
Indexed on
2012/03/28
17:29 UTC
Read the original article
Hit count: 224
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 :/
© Stack Overflow or respective owner