Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 02, 2010 04:58 PM by rickjackson
Jun 23, 2007 10:57 AM|LINK
I am trying to freeze gridview header
I placed my gridview inside
<div id="divGridViewHeader" style="position:relative; height:150px; overflow:auto">
this is my gridview header css class
and in gridview HeaderStyle's CssClass property I assign this class
Till now grid view works fine and i am also able to freeze its header.
But when i add following code in grid view's RowDataBound event
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowIndex >= 0)
if (e.Row.RowIndex % 2 == 0)
GridView's Header start to move upwards as soon as i scroll down.
Do anybody have any solution
then please reply.
ASP.NET 2.0 fixed GridView Header
ASP.NET 2.0 Freezing GridView Header
Jun 24, 2007 11:00 AM|LINK
Check this http://www.codeproject.com/useritems/FreezeHeader.asp
Feb 07, 2008 10:11 AM|LINK
This is working fine. But when the gridview is inside a div and having 10 coloums, then the header text is going beyond the screen. It is not fitting inside the div. Any way to fit inside the div.
Feb 07, 2008 02:50 PM|LINK
I don't know why it wouldn't work for you because it works me. Are you sure that the mouseover is not being invoked on the header? That would wipe out the positioning and cause what you describe.
Change if (e.Row.RowIndex >= 0) to if ( e.Row.RowType == DataControlRowType.DataRow )
I would also suggest changing your onmouseout as follows, unless you're actually setting the CSSClass property of the rows initially.
Feb 08, 2008 03:05 AM|LINK
I think your code will be like this
<div id="divGridView" style="height:400px;">
YOUR GRIDVIEW HERE
When I faced such problem, I solved it by adding position:relative in div tag
<div id="divGridView" style="height:400px; width:100%; position:relative">
Hope this helps !!!
Feb 08, 2008 03:12 AM|LINK
Thanks for your help.
Now I have solved that problem and Gridview is working just fine in IE.
and I am absolutely sure if ( e.Row.RowIndex >= 0 ) and if ( e.Row.RowType == DataControlRowType.DataRow) are same
but in Former I can work with numeric values
Actually RowIndex of Header and Footer row is -1.
Feb 08, 2008 09:15 AM|LINK
If i am applying position:relative to div nothing happens. Header will come inside div normally. But its not freezing.
Feb 10, 2008 11:03 AM|LINK
Can you write your code here, including CSS class ?
Feb 10, 2008 01:59 PM|LINK
Are you using Internet Explorer? What is posted will ONLY work in IE.
Feb 11, 2008 02:36 AM|LINK
Hi My dear friends,
At last i got it. This is the code what i used. Now its working fine. But it will work only in IE 5+.
/* Locks the left column */
/* Locks table header */
/* Keeps the header as the top most item. Important for top left item*/
But one problem. It will not working if we have two or more grid in same page.
Any one having solution for this, then plz let me know.