after posting another questions which seems to be difficult to answer(http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24326178.html
), i just want to ask for a different approach to the problem. My goal is the following:
1. Create a table (datalist or whatever control you suggest) that holds a variable number of columns. The column names are retrieved using a database query. There are three static columns that are always there: "Name" should be the second column in the table, "Active" the last. The column retrieved with the query should be in between those two. Name holds a label, Active an Image. Each row holds a button(edit button) in the first column (to the left of the "Name" column).
2. The columns retrieved from the database hold a label in each row to display text.
3. If the edit button is clicked, the "Name" columns label is turned into a Textbox, the Image for Active into a Checkbox. The labels in the dynamically added columns turn into Textboxes. The first column now holds a save and cancel imagebutton.
4. On cancel the row goes back to normal display state with labels and image.
5. On save the values entered by the user are saved to the database
My question is now how do i achieve this? The way im currently doing it (see my other question) does not work as i loose the state of the dynamically created Textboxes during postbacks. Please lay out some code which does exactly this. You dont need to provide the database code or code for cancel as i have that already. Im only interested how and especially in which methods to create the dynamic controls and how to make sure to keep their state once the save button is clicked. (The tricky part seems to be where to create the dynamic controls in order to have their viewState managed)