1.用Css来定制DataGrid表头HeaderStyle的cssclass属性

.fixTitle
{
 /*background: navy;
 color: white;*/
 position: relative;
 top: expression(this.offsetParent.scrollTop);
}



 

 1[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)    <DIV style="Z-INDEX: 102; LEFT: 264px; OVERFLOW: auto; WIDTH: 184px;TOP: 128px; HEIGHT: 216px"
 2[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)                ms_positioning="GridLayout">
 3[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)                <asp:DataGrid id="DataGrid1" style="Z-INDEX: 103;" runat="server" BorderColor="#DEBA84" BorderStyle="None"
 4[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)                    BorderWidth="1px" BackColor="#DEBA84" CellPadding="0">
 5[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)                    <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#738A9C"></SelectedItemStyle>
 6[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)                    <ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
 7[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)                    <HeaderStyle Font-Bold="True" ForeColor="White" CssClass="fixTitle" BackColor="#A55129"></HeaderStyle>
 8[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)                    <FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></FooterStyle>
 9[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)                    <PagerStyle HorizontalAlign="Center" ForeColor="#8C4510" Mode="NumericPages"></PagerStyle>
10[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)                </asp:DataGrid></DIV>


注意DataGrid的position不能是绝对位置!

2.孟大哥的方法
http://dotnet.aspx.cc/ShowDetail.aspx?id=B3F3462D-DC34-41CE-9FEE-6965B2A3D1AD

相关文章: