0

I have the following code:

<%# IIf(IsDBNull(Container.DataItem("idQuestionaire")), Me.pnlAdd.Visible = True, Me.pnlRemove.Visible = True)%> 

<asp:Panel ID="pnlAdd" runat="server" Visible="false">
        add
</asp:Panel>

<asp:Panel ID="pnlRemove" runat="server" Visible="false">
        remove
</asp:Panel>

So I want that if the Container item is NULL that the "pnlAdd" is Visible.

But I get the following error:

pnlAdd is not member of mySite.aspx

2
  • check your file name, did you rename or move it? check/post your first line of .aspx here, check/post your class name in the code behind here? Commented Oct 26, 2015 at 14:48
  • Did you try shifting IIf below the panels? Commented Oct 26, 2015 at 14:49

2 Answers 2

3

Seems like the context isn't correct, not sure if you can do this type of thing from within a data-binding expression. Try setting it by directly embedding it in the markup e.g.

<asp:Panel ID="pnlAdd" runat="server" Visible="<%# IsDBNull(Container.DataItem("idQuestionairre")) %>">
    add
</asp:Panel>

<asp:Panel ID="pnlAdd" runat="server" Visible="<%# !IsDBNull(Container.DataItem("idQuestionairre")) %>">
    remove
</asp:Panel>
Sign up to request clarification or add additional context in comments.

Comments

0

SOLUTION:

I used this code:

         <asp:LinkButton ID="lbtnAdd" runat="server"  Text="::Add" Visible='<%# IIf(IsDBNull(Container.DataItem("idQuestionaire")), "true", "false")%>'></asp:LinkButton>
                <asp:LinkButton ID="lbtnRemove" runat="server"  Text="::Remove" Visible='<%# IIf(IsDBNull(Container.DataItem("idQuestionaire")), "false", "true")%>'></asp:LinkButton>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.