Microsoft.NET

……………………………………………….Expertise in .NET Technologies

Freezing GridView Column Headers

Posted by Ravi Varma Thumati on May 12, 2009

For Freezing GridView Header column

Put GridView in Panel or Div Tag.

  < asp:Panel runat=”server” style=”height:300px; width:700px;” >

 < asp:GridView runat=”server” AllowPaging=”False” AllowSorting=”True”
                AutoGenerateColumns=”False” DataKeyNames=”id” DataSourceID=”SqlDataSource1″ Width=”700px” BorderWidth=”0″ >
                < Columns >
      < asp:BoundField DataField=”id” HeaderText=”ID” SortExpression=”id” / >
          < / Columns >

  </asp:Panel> 

Next create freez Css Class

Next, I created the container css style class as Mitch suggests …

/* So the overflow scrolls */
.freez {overflow:auto;}

/* Keep the header cells positioned as we scroll */
.freez table th {position:relative;}

/* For alignment of the scroll bar */
.freez table tbody {overflow-x:hidden;}

But,Problem is that it work fine in IE but not in FireFox.                                        

 

Advertisements

One Response to “Freezing GridView Column Headers”

  1. Kailash said

    It won’t give you desired result when parent control or the page itself has scroll bar. As the GridView header is assigned fixed position, all the contents will scroll, but the header.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: