Solved

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

Posted on 2013-10-27
1
547 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39603978
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

730 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