0

I have a control with the visible property set to the value of a boolean field. However, I want the visiblity to be the opposite of the boolean field. How do I do this?

This code shows the visible property set to the value of the field. I want to negate that value.

<span runat="server" id="toMonthYear" visible='<%#Eval("isAttending")%>'>
     <%#Eval("toMonthName")%> 
</span>
dmr
  • 21,811
  • 37
  • 100
  • 138

2 Answers2

3

Simply cast it to bool and use the negation operator (NOT in VB.NET).

Visible='<%# !(bool)Eval("isAttending") %>'
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
1

Try this

<span runat="server" id="toMonthYear" visible='<%#(!Boolean.Parse(Eval("isAttending"))%>'>
Sachin
  • 40,216
  • 7
  • 90
  • 102