Code
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> GridView Fixed Header clear moon http://blog.csdn.net/21aspnet </title>
<Style>
. Freezing
{
Position: relative;
Table-layout: fixed;
Top: expression (this. offsetParent. scrollTop );
Z-index: 10;
}
. Freezing th {text-overflow: ellipsis; overflow: hidden; white-space: nowrap; padding: 2px ;}
</Style>
</Head>
<Body style = "font-size = 12px">
<Form id = "form1" runat = "server">
<Div style = "overflow-y: scroll; height: 200px; width: 300px" id = "dvBody">
<Asp: GridView ID = "GridView1" runat = "server" AutoGenerateColumns = "False" CellPadding = "3" OnRowDeleting = "GridView1_RowDeleting" OnRowEditing = "GridView1_RowEditing"
OnRowUpdating = "GridView1_RowUpdating" OnRowCancelingEdit = "regular" BackColor = "White" BorderColor = "# CCCCCC" BorderStyle = "None" BorderWidth = "1px" Font-Size = "12px" OnRowCreated = "GridView1_RowCreated">
<FooterStyle BackColor = "White" ForeColor = "#000066"/>
<Columns>
<Asp: BoundField DataField = "ID card number" HeaderText = "no." ReadOnly = "True"/>
<Asp: BoundField DataField = "zip code" HeaderText = "zip code" SortExpression = "zip code"/>
<Asp: BoundField DataField = "Home Address" HeaderText = "Home Address"/>
<Asp: BoundField DataField = "name" HeaderText = "name"/>
</Columns>
<RowStyle ForeColor = "#000066" type = "regxph" text = "yourobjectname"/>
<SelectedRowStyle BackColor = "#669999" Font-Bold = "True" ForeColor = "White"/>
<PagerStyle BackColor = "White" ForeColor = "#000066" HorizontalAlign = "Left" CssClass = "ms-formlabel DataGridFixedHeader"/>
<HeaderStyle BackColor = "#006699" Font-Bold = "True" ForeColor = "White" CssClass = "Freezing"/>
</Asp: GridView>
</Div>
</Form>
</Body>
</Html>