Showing/Hiding a Panel in a Repeater

Tech-Archive recommends: Fix windows errors by optimizing your registry



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.


.



Relevant Pages

  • Re: Get the text of panels of status bar
    ... > Is it possible to get the text of the different panels of the status bar ... > that belongs to an external application? ... As String ... Dim sText As String ...
    (microsoft.public.vb.winapi)
  • Open net cf - StatusBarEx design error?
    ... I've tried working with the StatusBarEx and I get design time errors when ... I'm putting some panels on it. ... Object reference not set to an instance of an object. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Object reference not set to an instance of an object
    ... I want to access in code-behind a label within the ItemTemplate of a ... <ItemTemplate> ... Dim name As String = CType, ... "Object reference not set to an instance of an object" ...
    (microsoft.public.dotnet.framework.aspnet)
  • Object reference not set to an instance of an object
    ... I want to access in code-behind a label within the ItemTemplate of a ... <ItemTemplate> ... Dim name As String = CType, ... "Object reference not set to an instance of an object" ...
    (microsoft.public.dotnet.framework.aspnet)
  • Object reference not set to an instance of an object
    ... I want to access in code-behind a label within the ItemTemplate of a ... <ItemTemplate> ... Dim name As String = CType, ... "Object reference not set to an instance of an object" ...
    (microsoft.public.dotnet.framework.aspnet)