Click here to Skip to main content
15,896,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make the header in gridview as static which means that if i add any rows in the gridview the header should not move.

Please tell me the code.
Posted
Comments
Sandeep Mewara 3-May-12 4:51am    
Web or Winforms?

1 solution

Please refer following links:
some articles on CP:
Grid View with Fixed Header[^]
Gridview Fixed Headers[^]

A Scrollable GridView with a Fixed Header in .NET[^]
jQuery Fixed Header Scrollable GridView[^]
GridView Fixed Header[^]

some solved answers:
gridview scroll with fixed header and footer[^]
Scrollable GridView with fixed headers in asp.net[^]

Gridview Fixed Header Issue[^]

Or else
Try this:

Create a CSS file "grid.css" within a folder "css" with a class "grid-header".The css folder is under the root directory

CSS
.grid-header
{
font-weight: bold;
font-family: Verdana;
font-size: 11px;
background-color: #7A9FCB;
text-decoration: underline;
color: #ffffff;
text-align: left;
position: relative;
top:expression(this.parentNode.parentNode.parentNode.scrollTop-2);
left:expression(this.parentNode.parentNode.parentNode.scrollLeft-1);
right:1px;
}


Call this CSS File from your page which is contain your grid
link href="../css/grid.css" rel="stylesheet" type="text/css" /

call this css from the HeaderStyle of your gridview
HTML
<HeaderStyle CssClass="grid-header"></HeaderStyle>
 
Share this answer
 
v4
Comments
codeBegin 3-May-12 8:01am    
Nice collection of links!
Prasad_Kulkarni 3-May-12 8:49am    
Thank You Sarian!
sangel1989 9-May-12 7:42am    
Simply great, my 5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900