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>

2

3

4

5

6

7

8

9

10

注意DataGrid的position不能是绝对位置!
2.孟大哥的方法
http://dotnet.aspx.cc/ShowDetail.aspx?id=B3F3462D-DC34-41CE-9FEE-6965B2A3D1AD