Hi ramco1917,
Please refer below sample.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.table tr td {
padding-top: 0px !important;
padding-bottom: 0px !important;
width: 25px;
}
.table {
margin-bottom: 0px !important;
}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
</head>
<body>
<form id="form1" runat="server">
<table class='table table-bordered table-hover' id='tblParticipant'>
<thead>
<tr>
<th class='nosort2 text-center'>#</th>
<th class="text-center">Id</th>
<th>Name</th>
<th class="text-center" colspan="3"></th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rptCustomers" runat="server" OnItemDataBound="OnItemDataBound">
<ItemTemplate>
<tr>
<td><asp:Literal ID="ltrlNum" runat="server" Text="<%# Convert.ToString(Container.ItemIndex + 1) %>"></asp:Literal></td>
<td><asp:Label ID="lblId" runat="server" Text='<%#Eval ("CustomerId") %>' /></td>
<td><asp:Label ID="lblName" runat="server" Text='<%#Eval ("ContactName") %>' /></td>
<td>
<table class='table table-bordered table-hover' id='tblNominee'>
<thead>
<tr>
<th class="text-center">OrderId</th>
<th class="text-center">Price</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rptOrders" runat="server">
<ItemTemplate>
<tr>
<td><asp:Literal ID="ltrlId" runat="server" Text='<%# Eval("OrderId") %>'></asp:Literal></td>
<td><asp:Literal ID="ltrlFreight" runat="server" Text='<%# Eval("Freight") %>'></asp:Literal></td>
<td>
<asp:LinkButton ID="lnkNomiee" runat="server" class="navbar-nav-link font-weight-semibold">
<span class="text-pink"><i class="icon-folder-upload mr-1"></i>Add Nominee</span>
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
</form>
</body>
</html>
Namespaces
C#
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.UI.HtmlControls;
VB.Net
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Web.UI.HtmlControls
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
rptCustomers.DataSource = GetData("SELECT TOP 3 * FROM Customers");
rptCustomers.DataBind();
}
}
protected void OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string customerId = (e.Item.FindControl("lblId") as Label).Text;
Repeater rptOrders = e.Item.FindControl("rptOrders") as Repeater;
rptOrders.DataSource = GetData(string.Format("SELECT TOP 3 * FROM Orders WHERE CustomerId='{0}'", customerId));
rptOrders.DataBind();
}
}
private static DataTable GetData(string query)
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand(query, con))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
return dt;
}
}
}
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
rptCustomers.DataSource = GetData("SELECT TOP 3 * FROM Customers")
rptCustomers.DataBind()
End If
End Sub
Protected Sub OnItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim customerId As String = (TryCast(e.Item.FindControl("lblId"), Label)).Text
Dim rptOrders As Repeater = TryCast(e.Item.FindControl("rptOrders"), Repeater)
rptOrders.DataSource = GetData(String.Format("SELECT TOP 3 * FROM Orders WHERE CustomerId='{0}'", customerId))
rptOrders.DataBind()
End If
End Sub
Private Shared Function GetData(ByVal query As String) As DataTable
Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(constr)
Using cmd As SqlCommand = New SqlCommand(query, con)
Using sda As SqlDataAdapter = New SqlDataAdapter(cmd)
Using dt As DataTable = New DataTable()
sda.Fill(dt)
Return dt
End Using
End Using
End Using
End Using
End Function
Screenshot