Click here to Skip to main content
Click here to Skip to main content
Alternative Tip
Go to top

How to Freeze GridView Header While Scrolling ?

, 14 Mar 2010
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author

Pranay Rana
Software Developer (Senior) GMind Solusion
India India

Microsoft C# MVP (12-13)

 
Hey, I am Pranay Rana, working as a ITA in 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:


Follow on   Twitter   LinkedIn

Comments and Discussions

 
GeneralGridView With Fixed Headers in Asp.Net Using C# and jQuery PinmemberBinu198521-Jun-14 0:01 
QuestionDidn't work in IE9 Pinmembercdraghavendra28-Jan-14 5:02 
GeneralMy vote of 5 Pinmemberlakshmanbalanagu19-May-13 2:26 
GeneralReason for my vote of 4 this is really good and easy solutio... PinmemberAvi_Jai10-Nov-11 7:08 
GeneralYou should rewrite your aspx code( encode html ) PinmemberXmen W.K.9-Sep-10 4:41 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140926.1 | Last Updated 15 Mar 2010
Article Copyright 2010 by Pranay Rana
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid