[总结]DataGrid 固定表头实现(纵向和横向滚动条滚动,而Header不动)

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

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



 

 1    <DIV style="Z-INDEX: 102; LEFT: 264px; OVERFLOW: auto; WIDTH: 184px;TOP: 128px; HEIGHT: 216px"
 2                ms_positioning="GridLayout">
 3                <asp:DataGrid id="DataGrid1" style="Z-INDEX: 103;" runat="server" BorderColor="#DEBA84" BorderStyle="None"
 4                    BorderWidth="1px" BackColor="#DEBA84" CellPadding="0">
 5                    <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#738A9C"></SelectedItemStyle>
 6                    <ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
 7                    <HeaderStyle Font-Bold="True" ForeColor="White" CssClass="fixTitle" BackColor="#A55129"></HeaderStyle>
 8                    <FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></FooterStyle>
 9                    <PagerStyle HorizontalAlign="Center" ForeColor="#8C4510" Mode="NumericPages"></PagerStyle>
10                </asp:DataGrid></DIV>


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

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

posted @ 2005-08-15 13:57  PointNet  阅读(5699)  评论(5编辑  收藏  举报