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
<asp:Repeater ID="rptData" runat="server">
<HeaderTemplate>
<table>
<thead>
<th>ProductName</th>
<th>CategoryName</th>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:HiddenField ID="ProductID" runat="server" Value='<%# Eval("ProductID") %>' />
<asp:Literal ID="ProductName" Text='<%# Eval("ProductName") %>' runat="server"></asp:Literal>
</td>
<td><asp:Literal ID="CategoryName" runat="server" Text='<%# Eval("CategoryName") %>'></asp:Literal></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody> </table>
</FooterTemplate>
</asp:Repeater>
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)
{
string ConString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(ConString))
{
using (SqlCommand cmd = new SqlCommand("SELECT TOP 5 ProductID,ProductName,c.CategoryName FROM Products p INNER JOIN Categories c ON p.CategoryID = c.CategoryID ORDER BY ProductID", con))
{
con.Open();
rptData.DataSource = cmd.ExecuteReader();
rptData.DataBind();
con.Close();
}
}
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim ConString As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
Using con As SqlConnection = New SqlConnection(ConString)
Using cmd As SqlCommand = New SqlCommand("SELECT TOP 5 ProductID,ProductName,c.CategoryName FROM Products p INNER JOIN Categories c ON p.CategoryID = c.CategoryID ORDER BY ProductID", con)
con.Open()
rptData.DataSource = cmd.ExecuteReader()
rptData.DataBind()
con.Close()
End Using
End Using
End If
End Sub
Screenshot