Solved

ASP.Net Label show Yes or No for a bit field and handle nulls

Posted on 2013-10-27
1
515 Views
Last Modified: 2013-10-28
I have an asp.net page that displays the answers to questions. The data is in a SQL Server 2008 database as a bit field. If the answer is true, I want to display "Yes" and false show "No". What I have is below:
<asp:label ID="test" runat="server" Text='<%# Eval("Field").ToString() == "True" ? "Yes":"No" %>'
This shows either Yes or No, but the problem is that if the field is not answered (it's null), then it shows No. I want it to display nothing. Can this be done? I'm using C# and VS 2008. Thanks.
0
Comment
Question by:dodgerfan
1 Comment
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
Comment Utility
Hi dodgerfan;

Try it like this see it works.

<asp:label ID="test" runat="server" Text='<%# Eval("Field").ToString() == "True" ? "Yes": Eval("Field").ToString() == "False" ? "No" : "" %>'

Open in new window

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

762 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

7 Experts available now in Live!

Get 1:1 Help Now