The table header does not move and the table body is scrolled.
First look at the effect:
Mencius has done this before, but his method is required in front-end and back-end. It is still VB (^-^). It does not seem to support the DataGrid like my auto-generated columns, therefore, it is very easy to implement scripts by yourself. Just a few lines:
Function Scrolldatagrid ()
{
VaR TB = Document. getelementbyid ( " Tbheader " );
VaR DG = Document. getelementbyid ( " Dgsearchresult " );
If (DG ! = Null )
{
VaR DV = Document. getelementbyid ( " Dvbody " );
VaR Th = DG. Rows [ 0 ];
For ( VaR I = 0 ; I < Th. cells. length; I ++ )
Th. cells [I]. Width = Th. cells [I]. clientwidth;
VaR Tr = Th. clonenode ( True );
// Tr. applyelement (TB );
TB. createthead ();
VaR Tbh = TB. thead;
Tbh. appendchild (TR );
Tr = Tbh. Rows [ 0 ];
VaR TD = Tr. insertcell ();
TD. style. Width = 19 ;
TD. Width = 19 ;
TD. innerhtml = Tr. cells [ 0 ]. Innerhtml;
Th. style. Display = 'None ';
If (DG. scrollheight < 300 )
DV. style. Height = DG. scrollheight * 1 + 2 ;
}
< Table Width = "100%" Border = "0" ID = "Tbheader" Cellpadding = "4" Cellspacing = "0" >
</ Table >
< Div Style = "OVERFLOW-Y: Scroll; Height: 300px" ID = "Dvbody" >
< ASP: DataGrid ID = "Dgsearchresult" Style = "Border-collapse: collapse" Runat = "Server" Width = "100%" Cellpadding = "4" Datakeyfield = "No" Borderwidth = "1px" Borderstyle = "Solid" Bordercolor = "Maid" Gridlines = "NONE" >
< Selecteditemstyle Forecolor = "Slategray" > </ Selecteditemstyle >
< Itemstyle Verticalalign = "Middle" > </ Itemstyle >
< Headerstyle Horizontalalign = "Center" > </ Headerstyle >
< Columns >
< ASP: buttoncolumn Text = "Select" Headertext = "& Lt; font face = webdings & gt; 6 & lt;/font & gt ;" Commandname = "Delete" >
< Headerstyle Wrap = "False" Width = "40px" > </ Headerstyle >
< Itemstyle Wrap = "False" Horizontalalign = "Center" > </ Itemstyle >
< Footerstyle Wrap = "False" > </ Footerstyle >
</ ASP: buttoncolumn >
</ Columns >
</ ASP: DataGrid > </ Div >