ASP.NET - problem to collapse ajac colapsable controll at server side

Asked By mani on 23-Nov-11 02:27 AM
hi..i have gridview and in each row i have ajax collapsepanel controll ..and it works fine..
but i have to colapse and extend at server side using code..
because afeter checking login coding only i need to collapse that controll..and extend like that..
how to do that..i done like below but not working..

 AjaxControlToolkit.CollapsiblePanelExtender clp = (AjaxControlToolkit.CollapsiblePanelExtender)Gridview1.Rows[row.RowIndex].FindControl("CollapsiblePanelExtender2");
 
 clp.Collapsed = true;
        clp.ClientState = "true";
Reena Jain replied to mani on 23-Nov-11 02:30 AM
hi,

check this code Set the ‘Collapsed’ property to true (collapses panel) or false (expands panel). Alternatively, setting the ‘ClientState’ to true (collapses panel) or false (expands panel) does the trick.
protected void btn_Collapse(object sender, EventArgs e)
  {
    // Expand
    this.CollapsiblePanelExtender1.Collapsed = false;
    this.CollapsiblePanelExtender1.ClientState = "false";
    // Collapse
    // Expand
    this.CollapsiblePanelExtender1.Collapsed = true;
    this.CollapsiblePanelExtender1.ClientState = "true";
  }

refer=> http://www.dotnetcurry.com/ShowArticle.aspx?ID=230
dipa ahuja replied to mani on 23-Nov-11 02:33 AM
Try this way <cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender2" runat="server" CollapseControlID="lbl2"
  ExpandControlID="lbl2" TargetControlID="Panel2" Collapsed="true">
</cc1:CollapsiblePanelExtender>
<asp:Label ID="lbl2" runat="server" Text="click" />
<asp:Panel ID="Panel2" runat="server" Width="300" BackColor="Gray">
  <asp:Panel ID="Panel3" BorderStyle="Solid" Width="300" BackColor="WhiteSmoke" runat="server"
    CssClass="ModalWindow">
    User name:
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
    Password :
    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
  </asp:Panel>
</asp:Panel>
 
mani replied to dipa ahuja on 23-Nov-11 03:00 AM
hi..i need to collapse taht extender controll in server side after checking login code..
so need to collapse using c# code..
Jitendra Faye replied to mani on 23-Nov-11 03:51 AM

Try this code-


protected

void buttonCollapseAll_click()

{


for(int i=0; i<GridView.Rows.Count; i++)

{

CollapsiblePanelExtender cpExt = (CollapsiblePanelExtender)GridView.Rows[i].Cells[3].FindControl(

"CollapsiblePanelExtender1") ; // If your template column is at 4th location

cpExt.Collapsed = true;

}

}



Try this and let me know.