Solved

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

Posted on 2013-10-27
1
545 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

829 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