CSS code
<Style type = "text/CSS">
. 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>
Call the code <Div style = "overflow-Y: Scroll; Height: 200px; width: 300px"> <! -- Set Div with scroll bar -->
<Asp: gridview id = "gridview1" runat = "server" autogeneratecolumns = "false" cellpadding = "3"
Backcolor = "white" bordercolor = "# cccccc" borderstyle = "NONE" borderwidth = "1px"
Font-size = "12px" datakeynames = "productid" datasourceid = "sqldatasource1" allowsorting = "true">
<Footerstyle backcolor = "white" forecolor = "#000066"/>
<Columns>
<Asp: commandfield showselectbutton = "true"/>
<Asp: boundfield datafield = "productid" headertext = "productid" readonly = "true" sortexpression = "productid"/>
<Asp: boundfield datafield = "supplierid" headertext = "supplierid" sortexpression = "supplierid"/>
<Asp: boundfield datafield = "productname" headertext = "productname" sortexpression = "productname"/>
<Asp: boundfield datafield = "categoryid" headertext = "categoryid" sortexpression = "categoryid"/>
</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>
<! -- Call the style Fixed Header -->
</Div>