Search code examples
asp.netinlineiif

ASP.NET inline code iif


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


Solution

  • 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>