Link to home
Create AccountLog in
Avatar of rpkhare
rpkhareFlag for India

asked on

How to collapse all the panels inside a repeater control

In my ASP.NET 3.5 web application, I have Web Form with a repeater control. Enclosed within the repeater control's ItemTemplate is Collapsible Panel Extender which binds a Panel Control somewhat in this way:
<asp:repeater ID="rpt1" runat="server">
      <ItemTemplate>
             <cc1:CollapsiblePanelExtender id="cpe1" runat="server" TargetControlId="panel1>
             </cc1:CollapsiblePanelExtender>
              <asp:Panel id="panel1" runat="server">
                      ----
                     -----
              </asp:Panel>
      </ItemTemplate>
</asp:repeater>

Open in new window


I have two buttons viz: Collapse and Expand. When I press Collapse, all panels must collapse inside the CollapsiblePanelExtender and when I press Expand, all panels must expand.

I tried little code like this on button click event:
Control ctl = new CollapsibleControlExtender.Controls[0];

CollapsiblePanelExtender cpe = new CollapsiblePanelExtender.FindControls("cpe1") as CollapsiblePanelExtender;

cpe.collapse = true;
cpe.ClientState = "true;

Open in new window


The problem with this code is that if 5 panels are displayed inside repeater control then only 1 gets collapsed. I want all the panels to be collapsed and expanded on button clicks.
ASKER CERTIFIED SOLUTION
Avatar of Anil Golamari
Anil Golamari
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of rpkhare

ASKER

Thanks. But I have solved the problem the other way.