문제

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>
도움이 되었습니까?

해결책

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

Visible='<%# !(bool)Eval("isAttending") %>'

다른 팁

Try this

<span runat="server" id="toMonthYear" visible='<%#(!Boolean.Parse(Eval("isAttending"))%>'>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top