473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DataGridView DataGridViewCheckBoxCell throws NullReferenceException

I have a datagridview control on a form with a few of the columns being
DataGridViewCheckBox. 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 NullReferenceException, although I know it is not
correct to do for normal program flow. What is the solution?

Aug 30 '06 #1
2 4858
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**********@yahoo.comwrote in message
news:11*********************@74g2000cwt.googlegrou ps.com...
>I have a datagridview control on a form with a few of the columns being
DataGridViewCheckBox. 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 NullReferenceException, 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**********@yahoo.comwrote in message
news:11*********************@74g2000cwt.googlegrou ps.com...
I have a datagridview control on a form with a few of the columns being
DataGridViewCheckBox. 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 NullReferenceException, 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
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...
1
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...
1
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...
3
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...
4
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,...
7
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...
1
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...
0
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...
2
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.