C# -- "Value==null"

Posted on 2009-12-23
Last Modified: 2013-12-17
How can I change the below so
"Checked" messageBox displays
since "Value==null" does not work,
since BLANK value "ID1" cells display
as {} in debug mode on attached ?
        private void designerMaintenanceBindingNavigatorSaveItem_Click(object sender, EventArgs e)
            for (int i = 0; i < designerMaintenanceDataGridView.Rows.Count; i++)
                if (designerMaintenanceDataGridView.Rows[i].Cells["ID1"].Value==null)
Question by:finance_teacher
    LVL 9

    Expert Comment

     if (designerMaintenanceDataGridView.Rows[i].Cells["ID1"].Value.Equals(null))
    should work if you really have null values
    LVL 9

    Accepted Solution

    or ..Equals(System.DBNull.Value)

    Author Comment

    if (designerMaintenanceDataGridView.Rows[i].Cells["ID1"].Value.Equals(null))  FAILS

    .Equals(System.DBNull.Value) WORKS

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    In my previous two articles we discussed Binary Serialization ( and XML Serialization ( In this article we will try to know more about SOAP (Simple Object Acces…
    A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now