vb.net inline IF with OR… not evaluating
-
23-09-2019 - |
문제
I'm working on a small problem where I'm trying to show/hide a panel based on two criteria
- A specific data field must not be blank
- The specific data filed must also not equal "Not Relocatable"
Unfortunately this doesn't seem to be working for me (note that setting either one or the other criteria works just fine.)
<asp:Panel runat="server" Visible='<%#If(Not String.IsNullOrEmpty(DataBinder.Eval(Container.DataItem, "_236")) Or Not DataBinder.Eval(Container.DataItem, "_236") = "Not Relocatable", True, False)%>'>
<tr>
<td>
</td>
<td class="align-right lightgreen">
Buyer would consider relocating a business, if it is:
</td>
<td>
</td>
<td colspan="3">
<%#DataBinder.Eval(Container.DataItem, "_236")%>
</td>
<td>
</td>
</tr>
</asp:Panel>
Can anyone lend a hand to rectify this problem for me?
해결책
The syntax <%# %>
is a data binding syntax, not an inline expression syntax. You cannot use procedural code inside of it like you can in the inline code <% %>
tags.
Data binding tags must contain a single Eval
or Bind
function. If you need to do conditional branching based on those functions, you will need to do it using inline code around the binding tags.
제휴하지 않습니다 StackOverflow