Hi
try this example:
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>">
<html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function OpenTable(table, img)
{
object = document.getElementById(table);
if (object.style.display=="")
{
object.style.display = "none";
img.src = "plus.gif";
}
else
{
object.style.display = "";
img.src = "minus.gif";
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" Runat="server" DataSourceID="SqlDataSource1" DataKeyNames="CustomerID"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateField SortExpression="CustomerID" HeaderText="CustomerID">
<ItemTemplate>
<img src="plus.gif" onclick='OpenTable("<%# CreateID(Eval("CustomerID"))%>", this);'/>
<asp:Label Runat="server" Text='<%# Bind("CustomerID") %>' ID="Label1"></asp:Label>
<br />
<table width=100% style="display:none;" id='<%# CreateID(Eval("CustomerID"))%>'>
<tr>
<td>
<asp:Label Runat="server" Text='<%# Bind("CompanyName") %>' ID="Label2"></asp:Label>
</td>
<td>
<asp:Label Runat="server" Text='<%# Bind("ContactName") %>' ID="Label3"></asp:Label>
</td>
<td>
<asp:Label Runat="server" Text='<%# Bind("ContactTitle") %>' ID="Label4"></asp:Label>
</td>
<td>
<asp:Label Runat="server" Text='<%# Bind("Address") %>' ID="Label5"></asp:Label>
</td>
<td>
<asp:Label Runat="server" Text='<%# Bind("City") %>' ID="Label6"></asp:Label>
</td>
<td>
<asp:Label Runat="server" Text='<%# Bind("Region") %>' ID="Label7"></asp:Label>
</td>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="SELECT [CustomerID], [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region] FROM [Customers]"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>">
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
in code behind:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
{
public string CreateID(object value)
{
return "Table_" + value.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
Hope it helps
Good Luck