views:

18

answers:

1

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?

A: 

Hey,

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
Brian
I've tried the UniqueID, ClientID and ID, all return null
Jack Mills
Could you post some small code samples of the UI and code if applicable? It's hard to tell. You are using the <asp:CheckBox> control, correct? Checkbox elements do not post back to the server if they are false, but the CheckBox control uses a hidden with the same ID as the check in case it is false, and that posts back. If you don't use that control, nothing would be in the form collection.
Brian
From what I read you can't access request.form information at page initialization
Jack Mills