?
Solved

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

Posted on 2013-10-27
1
Medium Priority
?
579 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 64

Accepted Solution

by:
Fernando Soto earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

809 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