473,698 Members | 2,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGridView DataGridViewChe ckBoxCell throws NullReferenceEx ception

I have a datagridview control on a form with a few of the columns being
DataGridViewChe ckBox. Whenever I click on the checkbox to create a new
record I get a NullReference Exception thrown even though I check for
NULL using System.Convert. IsDbNull function.

What gives?

I'm catching the NullReferenceEx ception, although I know it is not
correct to do for normal program flow. What is the solution?

Aug 30 '06 #1
2 4880
Without seeing some code I can only generalize.

NullRefference errors indicate that a method or property is being accessed
without its class being instantiated.

DBnull errors indicate that a Null is being returned from the DataBase and
its type is not recognized by the compiler.

In that case you can look into overriding, and handle it inside.

"Karen Hill" <ka**********@y ahoo.comwrote in message
news:11******** *************@7 4g2000cwt.googl egroups.com...
>I have a datagridview control on a form with a few of the columns being
DataGridViewChe ckBox. Whenever I click on the checkbox to create a new
record I get a NullReference Exception thrown even though I check for
NULL using System.Convert. IsDbNull function.

What gives?

I'm catching the NullReferenceEx ception, although I know it is not
correct to do for normal program flow. What is the solution?

Aug 31 '06 #2
How about setting the threestate property if the checkbox to true. This
will allow the checkbox to accept anything other than true or false.

Try that out.

Rick..

"Karen Hill" <ka**********@y ahoo.comwrote in message
news:11******** *************@7 4g2000cwt.googl egroups.com...
I have a datagridview control on a form with a few of the columns being
DataGridViewChe ckBox. Whenever I click on the checkbox to create a new
record I get a NullReference Exception thrown even though I check for
NULL using System.Convert. IsDbNull function.

What gives?

I'm catching the NullReferenceEx ception, although I know it is not
correct to do for normal program flow. What is the solution?

Aug 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5975
by: gregory_may | last post by:
This code seems to "work" but I get the following errors: An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll then this one: An unhandled exception of type 'System.ExecutionEngineException' occurred in system.windows.forms.dll Anyone know how to either trap these errors or prevent them from happening?
1
1631
by: Eduard Ralph | last post by:
Hi, I have a weird exception happening when calling the new operator. I'm not sure if this is the intended reaction to the situation or is actually a problem I've got. In any case a different error message would be helpful. I would like to know your thoughts on this problem. The situation: I have an external Library of C Functions and Structures which are
1
1717
by: Subrata | last post by:
hi All, I'm trying to call a COM component written in PowerBuilder from an ASP.NET application. The first method call into the COM component (developed using PB) is failing with 'Object reference not set to an instnace of an object' error. Observations: 1. I can call the same PB COM component from a .NET Windows application successfully. 2. I can call another COM component (developed using ATL COM, MSVC 6.0) from the ASP.NET application.
3
4649
by: Daniel Manes | last post by:
I need a strategy to debug this situation... I can't put all the code involved, but here are some of the critical lines with comments: ------------------------- Private _parentDataCell As DataGridViewCell 'declare private field _parentDataCell = _parentDataGrid.Rows(rowIndex).Cells(columnIndex) 'set to a specific cell Debug.Print(_parentDataCell.DataGridView.ToString) 'prints:
4
21298
by: Hexman | last post by:
Hello All, I'd like to find out the best way to add a cb column to a dgv and process efficiently. I see at least two ways of doing it. ------------------------------- 1) Add a cb to the dgv, iterate thru the dgv and update the bound fields if the cb has been checked. Then do the update and accept changes. How do I access the cb and its checked status? How to iterate thru dgv? Dim cbSelCol As New DataGridViewCheckBoxColumn
7
1977
by: Zytan | last post by:
I just got the strangest error. I have exception code that catches a null reference exception: catch (NullReferenceException ex) { ... } The handling code does nothing but print out data from within the object, ex. So, nothing is changed. And I've found that the exception object, ex, ITSELF is null! So, by accessing it to print its innards, it throws another NullReferenceException (which is, of course, unhandled)! Printing...
1
2787
by: weird0 | last post by:
I am assigning an arrlist to the datasource property of the datagridview. In short, i want to update the datagridview. But the moment, i assign it. The application crashes. It does not display the updated state of the datagridview neither throws any exception. Here is some of the following code: public void AddState(string stateName,float Prob) // Add a new state, to the arrlist { StateTable newState = new StateTable();
0
1647
by: Ryan Liu | last post by:
I have a program works fine in .NET 1.1 and just recompiled in .NET 2.0 without any code change. Compiles OK, but there is an exeception when execute it. Then I remove PK, it works all fine again. Is this a known bug : PK on auto increase DataColumn in DataTable cause NullReferenceException? dcLineId = new DataColumn(LINEID_STR,
2
2146
by: =?Utf-8?B?S2lt?= | last post by:
foreach (DataGridViewRow row in this.dataGridView.Rows) { if (row.Cells.Value.ToString() == "true") { return true; } } return false;
0
8611
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
9170
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
9031
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
8904
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
7741
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5867
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();...
0
4624
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
2
2341
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.