---
title: "Show/Hide Sections in a Datagrid row"  
description: "Show/Hide Sections in a Datagrid row"  
author: "Anonymous User"  
published: 2014-08-27  
updated: 2014-08-27  
canonical: https://www.mindstick.com/forum/2159/show-hide-sections-in-a-datagrid-row  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# Show/Hide Sections in a Datagrid row

I have a datagrid where each row has information on [Employees](https://www.mindstick.com/articles/44463/business-to-business-vat-reclaiming-a-guide-for-your-employees) in a company. I would like to allow each row the ability to show/hide [extra](https://www.mindstick.com/blog/63570/5-ways-to-make-money-with-the-extra-space-in-your-home) information. My first idea was use the CollapsiblePanelExtender from the [AJAX toolkit](https://www.mindstick.com/forum/210/implementing-watermark-text-in-jquery-as-similar-to-ajax-watermark-text-in-ajax-toolkit) and have each row like this:

```
<ajaxtoolkit:collapsiblepanelextender     TargetControlID="panel2">     ExpandControlID="LinkButton1"     CollapseControlID="LinkButton1"></ajaxtoolkit:collapsiblepanelextender><asp:panel>    FirstName | LastName | Phone | Email    <LinkButton1>  <- this hides/show extra info in panel2</asp:panel><asp:panel2>     <textbox ="FirstName">     <textbox ="LastName">     <textbox ="EmailName"></asp:panel2>
```

This works very well but it can be computationally expensive. The extra information [panel](https://www.mindstick.com/blog/11988/restructuring-corporate-offenses-government-appointed-panel-suggests-in-house-adjudication-system) has a lot of textboxes/[labels](https://www.mindstick.com/forum/34568/badges-labels-page-headers), all of which gets its [values](https://www.mindstick.com/forum/327/sum-textbox-values) from the [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax). Everytime the [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) loads all the [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) is got from the database at the start, some of it is hidden.

## Replies

### Reply by Sumit Kesarwani

Hi Ankit, \

GridViewRow row = ((GridViewRow)((ImageButton)sender).NamingContainer);

//NamingContainer return the container that the control sits in

DataKey key = ((GridView)row.NamingContainer).DataKeys[row.RowIndex];

//Retrieve data with a server method. It can be with wathever you want, I use an ArrayList

ArrayList AL=Domain.GetCustomerData(key[0].ToString());

//Fill controls with data,

LblDate.Text = AL[0].ToString();

dLectHidro.Value = AL[1].ToString();

idLectHL.Value = AL[2].ToString();

LblEstacion.Text = HttpUtility.HtmlDecode(AL[3].ToString());

TxtLluvia.Text = HttpUtility.HtmlDecode(AL[4].ToString());

TxtLluvia1.Text = HttpUtility.HtmlDecode(AL[5].ToString());

//Show the popup

this.ModalPopupModif.Show();


---

Original Source: https://www.mindstick.com/forum/2159/show-hide-sections-in-a-datagrid-row

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
