Hi ramco1917,
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
Please refer below sample.
HTML
<table class='table table-bordered table-hover' id='tblParticipant'>
<thead>
<tr>
<th class='nosort2'>#</th>
<th>Id</th>
<th>Name</th>
<th bgcolor="#4F81BD" align="center">
<font size="5" color="white" face="calibri">Nominee Details</font>
</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rptCustomers" runat="server" OnItemDataBound="rptParticipant_ItemDataBound">
<ItemTemplate>
<tr>
<td><asp:Literal ID="ltrlNum" Text="<%# Convert.ToString(Container.ItemIndex + 1) %>"
runat="server"></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-columned' id='tblNominee'>
<thead>
<tr>
<th style="width: 30%">OrderID</th>
<th style="width: 30%">CustomerID</th>
<th style="width: 20%">Freight</th>
<th style="width: 20%">ShipName</th>
</tr>
</thead>
<tbody>
<asp:Repeater ID="rptOrders" runat="server">
<ItemTemplate>
<tr>
<td><asp:Literal ID="ltrlOrderID" runat="server" Text='<%# Eval("OrderID") %>'></asp:Literal></td>
<td><asp:Literal ID="ltrlCustomerID" runat="server" Text='<%# Eval("CustomerID") %>'></asp:Literal></td>
<td><asp:Literal ID="ltrlFreight" runat="server" Text='<%# Eval("Freight") %>'></asp:Literal></td>
<td><asp:Literal ID="ShipName" runat="server" Text='<%# Eval("ShipName") %>'></asp:Literal></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
</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>
Namespaces
C#
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
VB.Net
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
rptCustomers.DataSource = GetData("SELECT TOP 2 * FROM Customers");
rptCustomers.DataBind();
}
}
protected void rptParticipant_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rptOrders = e.Item.FindControl("rptOrders") as Repeater;
rptOrders.DataSource = GetData(string.Format("SELECT TOP 2 * FROM Orders "));
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())
{
cmd.CommandText = query;
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
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 2 * FROM Customers")
rptCustomers.DataBind()
End If
End Sub
Protected Sub rptParticipant_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim rptOrders As Repeater = TryCast(e.Item.FindControl("rptOrders"), Repeater)
rptOrders.DataSource = GetData(String.Format("SELECT TOP 2 * FROM Orders "))
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()
cmd.CommandText = query
Using sda As SqlDataAdapter = New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Dim dt As DataTable = New DataTable()
sda.Fill(dt)
Return dt
End Using
End Using
End Using
End Function
Screenshot