How to handle nullable values - bool? int? etc...

Posted on 2013-02-05
Medium Priority
Last Modified: 2013-02-06
Language:  C#

Compiler is stopping on this line:

 cbBid1IsComplete.Checked = bid1.BidIsComplete;

Error says:

Error      193      Cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?)
Question by:Tom Knowlton
LVL 23

Accepted Solution

Roopesh Reddy earned 2000 total points
ID: 38858243

Then check for NULL, and assign the value -

if(bid1.BidIsComplete != null)
  cbBid1IsComplete.Checked = bid1.BidIsComplete.Value;

Open in new window

Hope it helps u...
LVL 13

Expert Comment

by:Jitendra Patil
ID: 38859564
check for Null Value and try to assing value as below
if(bid1.BidIsComplete !=Null)
  cvBid1IsComplete.Checked = true;

Open in new window


Author Closing Comment

by:Tom Knowlton
ID: 38861320

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Watch the video of Kernel Migrator for SharePoint, which demonstrate the process easily of migration from SharePoint to SharePoint, OneDrive for Business & Google Drive servers, Public Folder to SharePoint, File Server to SharePoint. The tool has va…
In the video, one can understand the process of resizing images in single or bulk. Kernel Bulk Image Resizer is an easy to use tool for resizing large number of images. One can add and resize multiple images with this tool in single go. The video sh…

627 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