65.9K
CodeProject is changing. Read more.
Home

How to Freeze GridView Header While Scrolling ?

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.50/5 (8 votes)

Mar 15, 2010

CPOL
viewsIcon

36966

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.net grid view