.Net in HTML tp return true if reader object not null, otherwise return false

Posted by Phill Healey on Stack Overflow See other posts from Stack Overflow or by Phill Healey
Published on 2012-10-06T11:20:19Z Indexed on 2012/10/07 21:37 UTC
Read the original article Hit count: 205

Filed under:
|
|
|

I'm using a DataList to show some data from the database and populating the fields on the html side. I now have a requirement to change the visibility of a panel based on whether or not a db field has data or not.

I need to be able to show the panel if the relevant data field has content, and hide it if it doesn't. Eg:

    <asp:Panel ID="pnlNew" runat="server" Style="margin:0; padding:0; width:42px; height:18px; bottom:5px; right:10px; float:right; position:relative; background:url(../_imgVideoBadge.png) no-repeat;" Visible='<%# Eval("cheese") != null %>' ToolTip="available"></asp:Panel>

Obviously this doesn't work in terms of the visible property. But hopefully it gives an idea of what I'm trying to achieve. Any help would be greatly appreciated.

I've seen examples previously of doing something along the lines of:

    a ?? b:c

How could this be applied to the above requirement??

Thanks in advance.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about .NET