Showing/Hiding a Panel in a Repeater
- From: "Kevin Humphreys" <khumphreys@xxxxxxxxxxx>
- Date: Thu, 9 Nov 2006 12:24:28 -0000
Hi,
I am trying to show and hide different panels in a row of a repeater pending
on the record that is returned.
Inside in the <ItemTemplate> I have a number of Panels and a function called
ShowPanel.
If the field "Panel" returns Panel1 then I was to show Panel1 and hide
Panel2, Panel3 and Panel 4.
If the field "Panel" returns Panel2 then I was to show Panel2 and hide
Panel1, Panel3 and Panel 4 etc.
<asp:repeater id="Repeater1" runat="server">
<ItemTemplate>
<div id='d<%# DataBinder.Eval(Container, "ItemIndex") %>' class="details">
<asp:Panel id="Panel1" runat="server">Panel1</asp:Panel>
<asp:Panel id="Panel2" runat="server">Panel2</asp:Panel>
<asp:Panel id="Panel3" runat="server">Panel3</asp:Panel>
<asp:Panel id="Panel4" runat="server">Panel4</asp:Panel>
<%# ShowPanel(Container.DataItem("Panel")) %>
</div>
</ItemTemplate>
</asp:repeater>
The ShowPanel funciton is as follows
Public Function ShowPanel(ByVal gender As String) As String
Select Case gender
Case "Panel1"
Panel1.Visible = True
Panel2.Visible = False
Panel3.Visible = False
Panel4.Visible = False
Case "Panel2"
etc...
End Select
Return Nothing
End Function
However when I do this I get the following error message
"System.NullReferenceException: Object reference not set to an instance of
an object."
Any ideas?
You help is much appreciated.
Regards,
Kevin Humphreys.
.
- Follow-Ups:
- Re: Showing/Hiding a Panel in a Repeater
- From: MikeS
- Re: Showing/Hiding a Panel in a Repeater
- Prev by Date: RE: Sections in repeater
- Next by Date: Control not in the list of controls for parameters
- Previous by thread: RE: Sections in repeater
- Next by thread: Re: Showing/Hiding a Panel in a Repeater
- Index(es):
Relevant Pages
|