Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have gridview in my ASP.Net web page in which I have Expand/Colapse as first column and Check box column in second. When ever I expand a column I should get check box for that rows only and hide when collapsed. Currently, I am handling this manually, but some other unusual thing happens. Is there any best way in this.
Please suggest
Thanks
Sreenath
Posted

1 solution

If You are using AJAX then below is solution

<code>
<asp:GridView ID="gvOrderEntry" AutoGenerateColumns="false" runat="server" ShowHeader="false">
<Columns><asp:TemplateField><ItemTemplate>
<tr> <td>
<asp:Panel ID="pnlExpander" runat="server"><asp:Image ID="imgCollapsible" ImageUrl="../Images/Collapse Down.gif" class="imgVA" runat="server" />
</asp:Panel>
</td></tr>
<tr><td>
<asp:Panel ID="pnlDetails" runat="server"><asp:
Add CheckBox here....
</asp:Panel>
<ajaxToolkit:CollapsiblePanelExtender ID="cpExtender" runat="Server" TargetControlID="pnlDetails" ExpandControlID="pnlExpander" CollapseControlID="pnlExpander" Collapsed="true" CollapsedSize="0" ExpandedImage="../images/Collapse Up.gif" CollapsedImage="../Images/Collapse Down.gif" ImageControlID="imgCollapsible" ExpandedText="expanded" CollapsedText="collapsed" ExpandDirection="Vertical" SuppressPostBack="true"> </ajaxToolkit:CollapsiblePanelExtender>
</td></tr>
</ItemTemplate></asp:TemplateField></Columns>
</asp:Gridview>
</code>

If AJAX is not used then you can add Gridview RowCommand event and handle imgCollapsible event by passing commandName.
Instead of asp:Image use asp:ImageButton, so that rowcommand event will fire. In RowCommand event you can set second <tr> visible true & false - which works similar to AJAX collapsible extender.

Regards,
Rashmi.MK
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900