Implementation of the GridView, the header is fixed, the table body has scrollbars and can be scrolled, here is a good example, I hope to help you.
Code as follows: <%@ Page language= "C #" autoeventwireup= "true"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <script runat=" "Server" > ///calculation data can be obtained from the data to see ICollection CreateDataSource () { System.Data.DataTable dt = new System.Data.DataTable (); System.Data.DataRow dr; dt. Columns.Add (New System.Data.DataColumn ("Student Class", typeof (System.String)); dt. Columns.Add (New System.Data.DataColumn ("Student Name", typeof (System.String)); dt. Columns.Add (New System.Data.DataColumn ("language", typeof (System.Decimal)); dt. Columns.Add (New System.Data.DataColumn ("Mathematics", typeof (System.Decimal)); dt. Columns.Add (New System.Data.DataColumn ("English", typeof (System.Decimal)); dt. Columns.Add (New System.Data.DataColumn ("Computer", typeof (System.Decimal)); for (int i = 0; i < i++) { System.Random rd = new System.Random (EnviroNment. TickCount * i);; dr = dt. NewRow (); dr[0] = "Class" + i.tostring (); dr[1] = "Test" + i.tostring (); dr[2] = System.Math.Round (rd. Nextdouble () * 2); dr[3] = System.Math.Round (rd. Nextdouble () * 2); dr[4] = System.Math.Round (rd. Nextdouble () * 2); dr[5] = System.Math.Round (rd. Nextdouble () * 2); dt. Rows.Add (DR); } System.Data.DataView dv = new System.Data.DataView (DT); return dv; } protected void Page_Load (object sender, EventArgs e) { if (! IsPostBack) { GridView1.Attributes.Add ("style", "table-layout:fixed"); Gridview1.datasource = CreateDataSource (); gridview1.databind (); } } </script> <script Type= "Text/javascript" > function S () { var t = document.getElementById ("<%=GridView1.ClientID%>" ); var t2 = T.clonenode (True) for (i = t2.rows.length-1; i > 0; i--) T2.DeleteRow (i) T.deleterow (0) A.appendchild (T2) } window.onload = s </script> <html xmlns= "http://www.w3.org/1999/xhtml" > <head> <title> to create a table head fix, Table-scrollable gridview</title> </head> <body> <form id= "Form1" runat= "Server" > <table> <tr> <td> <div id= "a" > </div> <div Style = "Overflow-y: scroll; height:200px "> <asp:gridview id=" GridView1 "runat=" Server "font-size=" 12px "backcolor=" #FFFFFF " Gridlines= "Both" cellpadding= "4" width= "560" > <headerstyle backcolor= "#EDEDED" height= "26px"/> </asp:GridView> </div> </td> </tr> </table> </form > </body> </html>