Hi ramco1917,
Using the below code i have created the example.
Check this example. Now please take its reference and correct your code.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
HTML
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<link href="GridviewScroll/gridviewScroll.css" rel="stylesheet" type="text/css" />
<script src="GridviewScroll/gridviewScroll.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#tbldata').gridviewScroll({
width: 450,
height: 300,
freezesize: 0,
headerrowcount: 1,
arrowsize: 30,
varrowtopimg: "Images/arrowvt.png",
varrowbottomimg: "Images/arrowvb.png",
harrowleftimg: "Images/arrowhl.png",
harrowrightimg: "Images/arrowhr.png"
});
});
</script>
<style type="text/css">
#tbldataPanelHeaderContent {
height: 35px;
}
</style>
<table class='table table-bordered table-hover datatable-highlight' id='tbldata'>
<tr>
<th>#</th>
<th>Name</th>
<th>City</th>
<th>Country</th>
</tr>
<asp:Repeater ID="rptData" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:HiddenField ID="hdfLeadId" runat="server" Value='<%# Eval("CustomerID") %>' />
<asp:Literal ID="ltrlNum" Text="<%# Convert.ToString(Container.ItemIndex + 1) %>" runat="server"></asp:Literal></td>
<td>
<asp:Literal ID="ltrlLeadNumber" runat="server" Text='<%# Eval("ContactName") %>'></asp:Literal></td>
<td>
<asp:Literal ID="ltrlParentName" runat="server" Text='<%# Eval("City") %>'></asp:Literal></td>
<td>
<asp:Literal ID="ltrlChildName" runat="server" Text='<%# Eval("Country") %>'></asp:Literal></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</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)
{
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
string query = "SELECT * FROM Customers";
using (SqlConnection con = new SqlConnection(conString))
{
SqlCommand cmd = new SqlCommand(query);
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
rptData.DataSource = dt;
rptData.DataBind();
}
}
}
}
}
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
Dim query As String = "SELECT * FROM Customers"
Using con As SqlConnection = New SqlConnection(conString)
Dim cmd As SqlCommand = New SqlCommand(query)
Using sda As SqlDataAdapter = New SqlDataAdapter()
cmd.Connection = con
sda.SelectCommand = cmd
Using dt As DataTable = New DataTable()
sda.Fill(dt)
rptData.DataSource = dt
rptData.DataBind()
End Using
End Using
End Using
End If
End Sub
Screenshot