Welcome to MSDN Blogs Sign in | Join | Help

How do I freeze an ASP.NET GridView header?

This question came up at the Public Sector Developer Conference in Anchorage, AK.  I'm trying to answer all customer questions like this via my blog so everyone has the benefit of the answer.  There are a number of ways to do it, but my favorite (because it so darn easy) is to use an ASP.NET AJAX control extender Dan Wahlin built.  I love reusable controls that make common tasks easier:).  The details and download for the extender is here.

-Marc

Published Tuesday, September 18, 2007 12:39 PM by Public Sector DPE Team

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: How do I freeze an ASP.NET GridView header?

You can also reproduce this behavior with a simple stylesheet element...  Much easier to work with and easy to implement!

Tuesday, September 18, 2007 4:06 PM by Pat

# re: How do I freeze an ASP.NET GridView header?

Tuesday, September 18, 2007 6:36 PM by David

# re: How do I freeze an ASP.NET GridView header?

I came across this yesterday, only seems to work in IE.

http://mattberseth.com/blog/2007/09/freezing_gridview_column_heade_1.html

Wednesday, September 19, 2007 7:22 AM by Dave

# re: How do I freeze an ASP.NET GridView header?

As pat pointed out implementing the style portion alone works.

Wednesday, September 19, 2007 8:41 AM by Michael T

# re: How do I freeze an ASP.NET GridView header?

how we slide from header like excel in 2.0 asp

Saturday, December 15, 2007 1:56 AM by pcs

# re: How do I freeze an ASP.NET GridView header?

Monday, February 04, 2008 5:46 AM by SA

# re: How do I freeze an ASP.NET GridView header?

ฺีBut every solution I found on internet that have a problem. If in your record have a dropdown list.It is a little bug for display.

Tuesday, February 12, 2008 6:43 AM by Krirk

# re: How do I freeze an ASP.NET GridView header?

Krirk, I believe a z-index on the header would fix the problem of a dropdownlist showing over it.  Please let me know if this is the problem you are talking about.

-Aaron B

Wednesday, March 26, 2008 3:31 PM by Aaron

# re: How do I freeze an ASP.NET GridView header?

Unless you are using IE 7 the z-index does not change the way a dropdown displays.  Basically the "select" is windowed, and does not play by the z-index rules.  I'm using IE 6 right now and the z-index does not change the way the dropdown displays over the gridview header.  I've been reading the IE 7 fixed this issue,  but that is not an option at my work yet.  Anyway,  the z-index does not change the dropdown displaying over the header.  FYI,  from what I have read,  the dropdown is the only control that does not play well with the z-index

Thursday, June 19, 2008 10:47 PM by Ben

# re: How do I freeze an ASP.NET GridView header?

Your solution just works if it's in one scrollable div. If it's in more scrollable div, it will go wrong, and I'm so headache with this problem. Can you solve it again and absolutely?

Thanks.

Thursday, September 18, 2008 5:18 AM by csharp

# re: How do I freeze an ASP.NET GridView header?

In IE6 I have the drop down that scrolls over the header of the gridview when scrolled. Is this issue been fixed? Kindly advise.

Friday, September 26, 2008 6:06 PM by rnc12345

# re: How do I freeze an ASP.NET GridView header?

paste below code in Style sheet and add this (CssClass="dropdownFix") attribute to dropdown control.

.dropdownFix

{

behavior:expression(this.style.visibility =(this.offsetParent.offsetParent.offsetParent.scrollTop-1) >(this.offsetParent.offsetTop - this.parentElement.parentElement.parentElement.firstChild.offsetHeight+1)? 'hidden' : 'visible');

z-index: 10;

}

Thursday, January 08, 2009 3:56 AM by Sai Prasad

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker