Friday, June 18, 2010

Alternative to Eval and an IF statement

The objective here was to show or hide a label depending on whether or not it has data. In Classic ASP we would've wrapped an if statement around it, but in ASP.NET we can set the visibility to True or False as demonstrated below.

Example:

<asp:Label ID="Label1" runat="server" Text='<%# Eval("ID")%>' Visible='<%# Eval("ID") > 0 %>'>

No comments:

Post a Comment