I'm trying to create multiple controls by using retrieved data from query, but preventing them from dissapearing on postback, allowing me to get and mantain their values, the problem I have is that I cannot create them on Init because the number of controls, their IDs, and other properties are only known after user selects an item on menu.
- Page loads a Menu with all its items and values (Data dependent), plus, a button is loaded too
- User clicks a item on menu.
- Selected value is used to perform a query by using a Dataset (This happens inside a function which is called from Menu_ItemClick event).
- Retrieved data from query is used to determine how many controls must be created (2, 4, 6, etc.). Each control has its unique ID, which is given according to data.
- Controls are created and placed into a Panel (named p).
- Now controls are visible and available for editing (RadioButtons, TextAreas)
- User clicks on button to save information from dynamic controls into a Database
Problems I'm facing
- Controls dissapear on postback when clicking button, because they weren't created on Init.
- Placing button on UpdatePanel to prevent whole page postback, makes dynamic controls not accesible when trying this:
For Each c In p.Controls
...
Next
The only control it gets is a single Literal control (Controls count is 1), as if other controls didn't exist.
Thank you in advance.