Persisting Dynamic Controls Over Postback

I have a datagrid that loads on page_load.

In this instance I can't load the datagrid in page_init as the results of the datagrid are determined by a checkbox and the checkbox would always be set to true during page_init thanks to the viewstate not being loaded.

I have an OnItemDataBound event on the datagrid that dynamically creates controls and later on I want to access the value of some of these controls (e.g. a text box)

Of course the problem is I can't access these controls values as they don't persist over a postback. Any idea how I can get round this problem?


You could put the code in Page_Init, and then check the value for the checkbox using the Request.Form collection to see if any change happened. That would be one way as in:

var value = Request.Form[this.chkCheck.UniqueID]; //may be ClientID

Need Your Help

Handling Multiple Gestures on a View

objective-c ios5 uiwebview uibutton uigesturerecognizer

Is there any way to detect a single tap vs. a scrolling gesture on a UIWebView? textfile split by line to combobox split text-files textfile split by line to combobox