Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

C# -- "Value==null"

Posted on 2009-12-23
3
Medium Priority
?
177 Views
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)
                {
                    MessageBox.Show("Checked");
                }
                else
                {
                    MessageBox.Show("UnChecked");
                }
            }
        }
0001.jpg
0
Comment
Question by:finance_teacher
  • 2
3 Comments
 
LVL 9

Expert Comment

by:Stephan_Schrandt
ID: 26115773
 if (designerMaintenanceDataGridView.Rows[i].Cells["ID1"].Value.Equals(null))
should work if you really have null values
0
 
LVL 9

Accepted Solution

by:
Stephan_Schrandt earned 2000 total points
ID: 26115778
or ..Equals(System.DBNull.Value)
0
 

Author Comment

by:finance_teacher
ID: 26115800
if (designerMaintenanceDataGridView.Rows[i].Cells["ID1"].Value.Equals(null))  FAILS

.Equals(System.DBNull.Value) WORKS
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Loops Section Overview
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…

580 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