Persisting Dynamically Created controls across Postback C#
Posted on 2008-10-22
I have a series of textboxes. I don't know many there are going to be so I'm creating them dynamcially.
I have 4 sections on my page. Each within Divs that hide and show one another, when buttons are pressed.
On the 3rd div I have the dynamcially loaded text boxes..
I've read that I need to create the textboxes, in the OnInit method of the page.
I try doing that.
The problem is I need a value from one section (the number of boxes to create) to actually build the textboxes. I tried putting it into a httpContext, Viewstate, and session. the problem is still the same...the Oninit executes first so it never gets my values. Since it never gets my values it never creates the boxes...
I need these boxes created and then when changed I need to update my database with the changed values. (Thus the reason why I need OnInit to create them. so that they stay there so I can use it doing the load process.)
I hope that is clear.
Any help would be great!