.Net in HTML tp return true if reader object not null, otherwise return false
- by Phill Healey
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.