By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,354 Members | 1,042 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,354 IT Pros & Developers. It's quick & easy.

Prerender and Gridview - Object reference not set to an instance ofan object.

P: n/a
In the Page_load my code check to see if session variable is set, if
it is, it calls some subroutines that loads some grids and binds them.

In my prerender, when the grids row is in update mode, and the key = 0
(meaning I'm inserting) I'd like to set a date field to current date.

the above logic works great in another page I have where I am not
checking for session information in the page load, but in th is code
results in the error.

Object reference not set to an instance of an object.

dumb question, in my prerender, how can check if my gridview has been
instantiated to avoid this error. I suspect this the problem. I guess
I could just wrap the whole thing in a try catch.

Actually, I just tried that and this does not seem to correct the
problem, I don't get the error, but I am unable to set the column.

Thanks for any help or information.

Mar 3 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Mar 3, 12:18*pm, wild...@noclient.net wrote:
In the Page_load my code check to see if session variable is set, if
it is, it calls some subroutines that loads some grids and binds them.

In my prerender, when the grids row is in update mode, and the key = 0
(meaning I'm inserting) I'd like to set a date field to current date.

the above logic works great in another page I have where I am not
checking for session information in the page load, but in th is code
results in the error.

Object reference not set to an instance of an object.

dumb question, in my prerender, how can check if my gridview has been
instantiated to avoid this error. I suspect this the problem. I guess
I could just wrap the whole thing in a try catch.

Actually, I just tried that and this does not seem to correct the
problem, I don't get the error, but I am unable to set the column.

Thanks for any help or information.
1) Usually it is better to do this kind of thing in DataBound event of
the control (here GridView).

2) It may be better to check the variable of concern for null (i.e. if
(someVar == null)) rather than forcing it go silent in try catch
block.
Mar 3 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.