I gone through lots of examples for fixed header grid view, and tried few options using div and java scripts. the one i didnot work from the example, is there anything i miss here.
CSS
.gridViewHeader
{
background-color:Navy;
color:blue;
font-size:12px;
font-weight:bold;
position:relative;
z-index:10;
top:expression(<%= gv.HeaderRow %>.offsetParent.scrollTop-2);
}
design source
<table>
<tr>
<td>
</td>
</tr>
</table>
<div>
<asp:GridView ID="gv" runat="server" CellPadding="4" PageSize="50" RowHeaderColumn="True"
AllowPaging="True" BackColor="White" BorderColor="#3366CC" BorderStyle="None"
BorderWidth="1px" CssClass="gridViewHeader">
<PagerSettings Mode="NumericFirstLast" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" VerticalAlign="Middle" />
<RowStyle BackColor="White" ForeColor="#003399" BorderStyle="Inset" HorizontalAlign="Center"
VerticalAlign="Middle" Wrap="False" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
</asp:GridView>
</div>
<asp:HiddenField ID="hiddenfield1" runat="server" />
</asp:Content>
you can use
<HeaderStyle CssClass="gridViewHeader" />
For your sample
<asp:GridView ID="gv" runat="server" CellPadding="4" PageSize="50" RowHeaderColumn="True"
AllowPaging="True" BackColor="White" BorderColor="#3366CC" BorderStyle="None"
BorderWidth="1px" >
<HeaderStyle CssClass="gridViewHeader" />
<PagerSettings Mode="NumericFirstLast" />
<PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" VerticalAlign="Middle" />
<RowStyle BackColor="White" ForeColor="#003399" BorderStyle="Inset" HorizontalAlign="Center"
VerticalAlign="Middle" Wrap="False" />
<SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
</asp:GridView>
This CSS will fix your problem:
.GVFixedHeader { font-weight:bold; background-color: Green; position:relative;
top:expression(this.parentNode.parentNode.parentNode.scrollTop-1);}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With