473,767 Members | 2,198 Online
Bytes | Software Development & Data Engineering Community
+ 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 3105
On Mar 3, 12:18*pm, wild...@noclien t.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
1409
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 DirectoryInfo = New DirectoryInfo(strFileNamePath) Dim aFiles As FileInfo() = dirInfo.GetFiles("*.doc") Array.Sort(aFiles, New CompareFileInfoEntries (CompareByOptions.LastWriteTime)) docList.DataSource = aFiles
4
1403
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 unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll 'Additional information: Object reference not set to an instance of an object.
1
1270
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 nrtb As New RichTextBox Sub DisplayMessage(ByVal rtb As RichTextBox, ByVal sText As String, Optional ByVal Colour As String = "") rtb.SelectionStart = rtb.Text.Length ' rtb.doColor(rtb, DirectCast(sText, String))
5
4877
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); trips the following error: Object reference not set to an instance of an object.
0
1518
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 pages. So far, I have had success in building the search form, and passing the values entered by the user from the form to a results page, and displaying the entire resultset using GridView. However, when I set the AllowPaging option on the...
3
15316
by: needin4mation | last post by:
In this code: protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRowView rowView = (DataRowView)e.Row.DataItem; // Retrieve the value for the current row.
1
7492
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 tried find control, and everything returns that I must reference and instance of the object. CommandArgument is being sent corrently. If the button where a ButtunField I apparently I could get the get the index, But I need the button to be an...
3
8876
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 that I call from the visible property of the gridview itemtemplate, the textbox is always blank. I tried setting the textbox in the prerender, but I suspect the
15
11673
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 "Select" <asp:GridView ID="grdDept" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="DocumentID" DataSourceID="sdsDepartment" Width="600px" CellPadding="4" ForeColor="#333333"...
0
9404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10009
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9838
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6651
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3929
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 we have to send another system
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.