Refer this code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
$("[src*=plus]").live("click", function () {
$(this).next("div").css('display', 'block');
$(this).attr("src", "images/minus.png");
});
$("[src*=minus]").live("click", function () {
$(this).attr("src", "images/plus.png");
$(this).next("div").css('display', 'none');
});
</script>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
.Grid td
{
background-color: #A1DCF2;
color: black;
font-size: 10pt;
line-height: 200%;
}
.Grid th
{
background-color: #3AC0F2;
color: White;
font-size: 10pt;
line-height: 200%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<img alt="" style="cursor: pointer" src="images/plus.png" />
<div style="display: none">
<table border="0" cellpadding="0" class="Grid" cellspacing="0">
<tr>
<th>
Id
</th>
<th>
Name
</th>
<th>
Country
</th>
</tr>
<tr>
<td>
<%# Eval("Id") %>
</td>
<td>
<%# Eval("Name") %>
</td>
<td>
<%# Eval("Country") %>
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>
Namespace
using System.Data;
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id"), new DataColumn("Name"), new DataColumn("Country") });
dt.Rows.Add(1, "John Hammond", "United States");
dt.Rows.Add(2, "Mudassar Khan", "India");
dt.Rows.Add(3, "Suzanne Mathews", "France");
dt.Rows.Add(4, "Robert Schidner", "Russia");
this.DataList1.DataSource = dt;
this.DataList1.DataBind();
}
}
Screenshot
