Scrollable GridView using JQuery

In this Artical i'm trying to explain about scrollable gridview with fixed Headers using JQuery. Why i'm introducing Fixed Headers means for reducing post back to the page and improve the performence of the page we introduce GridView with scrollable headers.

Scrollable GridView with fixed Headers usin JQuery:

I have a Gridview, in my GridView i have thousands of Rows. Previously i'm displaying my Grid using pagging concept. But now my comapny is not like that why because using Pagging, the page is post back on each and every page selection. To Overcome the above issue now i'm introduced the concept scrollable GridView with fixed headers. In my page it self header is fixed and if i want to see all rows using scrolling i want to move top to bottom and check the data. Using this we overcome the postback. Here i'm explain step by step process of this.


Creat CSS Class:

Using below styles we give some colors of the headers and set the position.

< style type="text/css">
font-weight: bold;
position: relative;
top: expression(this.parentNode.parentNode.parentNode.scrollTop-1);
border-top: 1px solid #AAAAAA;
background-color: #FFFFFF;


And call this class in GridView HeaderStyle and FoterStyle properties itself. Use the below sample code

<HeaderStyle Font-Bold="True" ForeColor="White" CssClass="GVFixedHeader" />
<PagerStyle ForeColor="White" HorizontalAlign="Center" CssClass="GridviewScrollPager" />


Add JQuery Plugins, for this we download from below link use the below link and download the plugins.

Using above links download JQuery plugins and add that to scripts folder.


After download JQuery plugins call that plugins using below lines of code

<script type="text/javascript" src="../Scripts/jquery1.8.2.min.js"></script>
<script type="text/javascript" src="../Scripts/jquery1.9.1.min.js"></script>
<script type="text/javascript" src="../Scripts/gridviewScroll.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {

function gridviewScroll() {
width: 1100,
height: 200


Design your page like below.

<asp:GridView runat="server" ID="GV"
<RowStyle BackColor="#EFF3FB" />
<PagerStyle BackColor="#2461BF" ForeColor="White"
HorizontalAlign="Center" /<
<HeaderStyle CssClass="GVFixedHeader" />
<FooterStyle CssClass="GVFixedFooter" />
<AlternatingRowStyle BackColor="White" />
<asp:TemplateField HeaderText="Material" HeaderStyle-Width="8%">
<asp:Label ID="lblMaterial" runat="server" Text='<%# Bind_Material(Convert.ToString(Eval("Material")))%>'/>
<asp:Label ID="lblMaterial_Id" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Material_Id") %>' Visible="false"/>
<asp:TemplateField HeaderText="Items" HeaderStyle-Width="8%" HeaderStyle-HorizontalAlign="center">
<asp:Label ID="lblItem" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Item") %>'/>
<asp:Label ID="lblItem_Id" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Item_Id") %>' Visible="false"/>
<asp:TemplateField HeaderText="Grade" HeaderStyle-Width="8%" HeaderStyle-HorizontalAlign="center">
<asp:Label ID="lblGrade" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Grade") %>'/>
<asp:Label ID="lblGrade_Id" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Grade_Id") %>' Visible="false"/>



In code behind wrote below lines of code and see the result

protected void Page_Load(Object sender, EventArgs e)
DataTable dt1= // bind your Data;
DataTable dt = new DataTable();
DataRow dr;
dr = dt.NewRow();
GV.DataSource = dt;
GV.Rows[0].Visible = false;

follow above mentioned all points and see the result.

Scrollable GridView using JQuery



Author: Phagu Mahato18 Sep 2013 Member Level: Gold   Points : 0

Thank you dear Naveen for posting a valuable resource on Scrollable GridView with fixed Headers using JQuery. I created in the Page Load event to Scrollable GridView JQuery

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Default2 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
SqlConnection connects = new SqlConnection(@"Data Source=.;Initial Catalog=erxample;Persist Security Info=True;User ID=Admin;Password=admin";
SqlDataAdapter adap = new SqlDataAdapter("select * from employee",connects);
DataSet dataset1=new DataSet();
GridView1.DataSource = dataset1.Tables["employee"];
GridView1.UseAccessibleHeader = true;
GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;

Author: naveensanagasetti18 Sep 2013 Member Level: Gold   Points : 2

Hi Phagu Mahato,

Can you please tell me what scenario did you use for scrolling purpose on here. I can't get your code properly what part is used for scrolling purpose..?
This code is used for biding grid purpose. Using this code Scrolling is possible...?
If it possible then please highlight that part...

Author: Jayakumar.R11 Sep 2015 Member Level: Gold   Points : 3


Good Post

But some issue in your code. Can you update them.

1. Where is in your grid name design side grid name this ---> gvdetails
But you mention server side how it will be work?

2.where is this method in your c# code?


3. How to invoke this line and go next step?

DataTable dt1= // bind your Data;

4. I try your complete code when will you bind records?

Dont mistaken me . I tried this source i face the issue so i point out

Author: naveensanagasetti11 Sep 2015 Member Level: Gold   Points : 5

Hi DotnetDeveloper,

Good points, I given just overview how to achieve it, any how I try to do modification for the same. But the resource is locked by editors, if any big issues only they will be unlocked I guess. I will provide the details for your understanding.

1. Where is in your grid name design side grid name this ---> gvdetails
But you mention server side how it will be work?

A) Yes, that's wrong we need to use the same gridview name.

2.where is this method in your c# code?


A) This is custom method to do some action while binding records in gridview, this is not a mandatory field for this requirement.

3. How to invoke this line and go next step?

DataTable dt1= // bind your Data;

A) In DataTable you can get your database data, if you have any method for that use that method and store the result in datatable.

Hope you understood.

Author: srikanth29 Sep 2015 Member Level: Silver   Points : 0

nice articles, its really helpful for my new project, thank you.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: