Click here to Skip to main content
15,868,016 members
Articles / Web Development / ASP.NET
Alternative
Tip/Trick

How to Freeze GridView Header While Scrolling ?

Rate me:
Please Sign up or sign in to vote.
4.50/5 (8 votes)
14 Mar 2010CPOL 36K   5   5
This thing is working for both horizontal and verticle scrolling. Here id of the div is hard coded but you can use jquery to attach css class to div element. div#gridPanel { width:900px; overflow:scroll; position:relative;}div#gridPanel th{ top:...
This thing is working for both horizontal and verticle scrolling.

Here id of the div is hard coded but you can use jquery to attach css class to div element.

div#gridPanel 
{
   width:900px;
   overflow:scroll;
   position:relative;
}


div#gridPanel th
{  
   top: expression(document.getElementById("gridPanel").scrollTop-2);
left:expression(parentNode.parentNode.parentNode.parentNode.scrollLeft);
   position: relative;
   z-index: 20;
}




aspx code

<asp:Panel ID="gridPanel" runat="server" Height="200px" Width="100px" ScrollBars="Auto">
   asp.net grid view
</asp:Panel>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India

Microsoft C# MVP (12-13)



Hey, I am Pranay Rana, working as a Team Leadin MNC. Web development in Asp.Net with C# and MS sql server are the experience tools that I have had for the past 5.5 years now.

For me def. of programming is : Programming is something that you do once and that get used by multiple for many years

You can visit my blog


StackOverFlow - http://stackoverflow.com/users/314488/pranay
My CV :- http://careers.stackoverflow.com/pranayamr

Awards:



Comments and Discussions

 
QuestionDidn't work in IE9 Pin
cdraghavendra28-Jan-14 5:02
cdraghavendra28-Jan-14 5:02 
GeneralMy vote of 5 Pin
lakshmanbalanagu19-May-13 2:26
lakshmanbalanagu19-May-13 2:26 
GeneralReason for my vote of 4 this is really good and easy solutio... Pin
Avi_Jai10-Nov-11 7:08
Avi_Jai10-Nov-11 7:08 
GeneralYou should rewrite your aspx code( encode html ) Pin
Xmen Real 9-Sep-10 4:41
professional Xmen Real 9-Sep-10 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.