문제

I'm working on a small problem where I'm trying to show/hide a panel based on two criteria

  1. A specific data field must not be blank
  2. 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top