views:

975

answers:

2

Using .NET 1.1, I have a DataGrid that contains three columns for each row.

Row one has a label with some text.

Row three will always have two radio buttons and two checkboxes and those are in the HTML side of the page.

Row two will have dynamically generated controls (just textboxes for now) and there can be 1 or more per row. These will be used for user input.

There is a button on the page and when the user clicks the button I need to update the DataGrid’s source (my DataTable) with the new values from the user’s input.

The issue is the DataGrid seems to be losing the dynamically generated controls on PostBack. I can loop through each Item in the DataGrid and I can access the radio buttons and the checkboxes, but the textboxes aren’t there.

Any ideas?

+2  A: 

Remember: every time a postback occurs you are working with a new instance of your page class. Dynamic controls added to the page during a previous postback went to the garbage collector as soon as the page for that postback rendered to the browser, along with the rest of that page instance. You need to re-create your dynamic controls on every postback.

Joel Coehoorn
A: 

you have to regenerate the controls. You should be able to get their values from the http request object

Corin