문제

I have a asp repeater and one of the items requires me to show or hide a text string depending upon the state of TWO boolean values

This works fine:

<asp:Label ID="X" runat="server" Text="yadayada" Visible='<%# (bool)DataBinder.Eval(Container.DataItem, "field1") %>'>

Unfortunately I need to compare two fields. I'm trying to for the logic as follows:

True + True = True
True + False = False
False + True = False

So I try this:

'<%# (bool)DataBinder.Eval(Container.DataItem, "field1") + (bool)DataBinder.Eval(Container.DataItem, "field1") %>' >

I also tried placing an "if" statement before the logic to do a typical c# or (||) evaluation but the compiler won't allow the "if"

Any help would be greatly apprecieated.

도움이 되었습니까?

해결책

You need to use && operator instead of +. Try using this:

Visible='<%# (bool)Eval("field1") && (bool)Eval("field1") %>'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top