ASP.Net Label show Yes or No for a bit field and handle nulls
Posted on 2013-10-27
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.