views:

8026

answers:

6

As in a title, does anyone know how to freeze GridView header in ASP.NET ?

+2  A: 

Option (a) buy into a UI package that includes a souped-up GridView with this functionality built-in.

Option (b) roll your own - it's not simple. Dino Esposito has one approach.

EDIT: Just noticed that the Dino article links to a subscriber-only area on the ASPnetPro magazine site.

Here's another approach using extenders.

Herb Caudill
+3  A: 

You can do it in the css

Freeze Header: 1. Define class .Freezing in Stylesheet:

.Freezing
{
   position:relative ;
   top:expression(this.offsetParent.scrollTop);
   z-index: 10;
}

2.Assign Datagrid Header's cssClass to Freezing

Galwegian
But it seems to work only under IE and not under FF :( Anyway, thanks! :)
rafek
Also, expressions no longer work in IE8.
Morten Christiansen
More specifically, expressions don't work in IE8 Standards mode.
EricLaw -MSFT-
+1  A: 

You can check this question.

korchev
+1  A: 

Give this a try should solve the problem http://www.codeproject.com/KB/webforms/FreezePaneDatagrid.aspx

rsapru
+2  A: 

Try this open-source project for ASP.NET. It extends GridView to provide fixed header, footer and pager and resizable column width. Works well in IE 6/7/8, Firefox 3.0/3.5, Chrome and Safari.

http://johnsobrepena.blogspot.com/2009/09/extending-aspnet-gridview-for-fixed.html

John
A: 

You may try the following sample

Freeze GridView Columns

Pon Saravanan