473,465 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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
1 3074
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Bandit | last post by:
I'm populating a gridview (called docList) with document info from a network folder like so: Sub Show_Files(ByVal inputDir As String) Dim strFileNamePath As String = inputDir Dim dirInfo As...
4
by: Supra | last post by:
I am doing irc chat similar to mirc chat if i connected to irc.webamster.com i had no problem. but if connected to eu.undernet.org. i got error....somthing bug me! O:-) 'February 2004 'An...
1
by: Supra | last post by:
'An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll 'Additional information: Object reference not set to an instance of an object. in module: Dim...
5
by: Joseph Geretz | last post by:
Here's my first attempt at DIME (code below signature). I'ts basically straight out of Microsoft's online sample: For some reason, the statement respContext.Attachments.Add(dimeAttach); ...
0
by: steve.craver | last post by:
I am working with a multi-field search form which, when the form is submitted, queries a database and returns the results into a paginated GridView object. The site is being developed with master...
3
by: needin4mation | last post by:
In this code: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView rowView =...
1
by: jobs | last post by:
Given the Gridview below: When I select the button "Rate" and fall into this code. How can I reference "carriercode" and others . Apparently selecting the button does not select the row. I've...
3
by: jc | last post by:
Hello. I have a gridview column item that i want to not make visible if the bound data in that cell is less than a value in a textbox. However, I notice at the time my code checks a function...
15
JustRun
by: JustRun | last post by:
I have a problem with the select option at the gridview and gonna pull my hair out cause it doesn't work at all. Here is the Grid view code: I want to get the selected row when the user click...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.