Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Prerender and Gridview - Object reference not set to an instance ofan object.

Reply
Thread Tools

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

 
 
wildman@noclient.net
Guest
Posts: n/a
 
      03-03-2008
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.

 
Reply With Quote
 
 
 
 
Muhammad Naveed Yaseen
Guest
Posts: n/a
 
      03-03-2008
On Mar 3, 12:18*pm, (E-Mail Removed) 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Object reference not set to an instance of an object" Weird thing happens with reference a link nguyentrongkha@gmail.com ASP .Net 1 09-20-2007 09:46 PM
Object reference not set to an instance of an object and ceate userwizard Fendi Baba ASP .Net 0 05-13-2007 04:45 PM
msnbot and Object reference not set to an instance of an object dev@thehexx.com ASP .Net 1 11-05-2004 03:40 PM
Error:Object reference not set to an instance of an object. Suresh Kojhani ASP .Net 1 07-29-2004 12:10 PM
Error !Object reference not set to an instance of an object. !!! Help Parthiv Joshi ASP .Net 2 07-02-2004 10:28 AM



Advertisments