APSX page code: JS
Copy Code code as follows:
<script src= ". /js/jquery-1.8.3.min.js "type=" Text/javascript "></script>-
<script src= ". /js/jquery-ui-1.10.3.custom.js "type=" Text/javascript "></script>
<script src= ". /js/gridviewscroll.min.js "type=" Text/javascript "></script>
<link href= ". /css/gridviewscroll.css "rel=" stylesheet "type=" Text/css "/>"
All the above documents can be downloaded directly from the Internet.
<script type= "Text/javascript" >
$ (document). Ready (function () {
Gridviewscroll ();
});
function Gridviewscroll () {
Because my GridView has to be in a div. So to get the corresponding height and width, the general direct digital setting is good
var gridwidth = $ ("#divservic"). width ();
var gridheight = $ ("#divservic"). Height ();
var headerheight = $ ("#divHeader"). Height ();
Gridheight = Gridheight-headerheight;
$ (' #<%=gridview2.clientid%> '). Gridviewscroll ({
width:gridwidth,//width must not be 100% can be directly written dead
height:gridheight,//height can be written directly to death
freezesize:4//control the first few columns do not move
});
}
Copy Code code as follows:
<div id= "Divservic" style= "WIDTH:100%;MARGIN-BOTTOM:2PX; height:220px; " >
<asp:gridview id= "GridView2" runat= "Server" cellpadding= "4" forecolor= "#333333" width= "100%"
Bordercolor= "#D1DDAA" allowpaging= "True" datakeynames= "Installationid"
Onpageindexchanging= "Gridview2_pageindexchanging"
Onrowdatabound= "Gridview2_rowdatabound"
onrowdeleting= "gridview2_rowdeleting" autogeneratecolumns= "False"
allowsorting= "True" onsorting= "gridview2_sorting" >
<rowstyle cssclass= "Gridviewscrollitem"/>>------------------------------------------------------------ -Here's the style to add
<footerstyle backcolor= "#1C5E55" font-bold= "True" forecolor= "white"/>
<pagerstyle cssclass= "Gridviewscrollpager"/>------------------------------------------------------------- Here's the style to add
<selectedrowstyle backcolor= "#C5BBAF"/>
<editrowstyle backcolor= "#7C6F57"/>
<alternatingrowstyle backcolor= "White" bordercolor= "#D1DDAA"/>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:checkbox id= "Ckbitem" runat= "Server"/>
</ItemTemplate>
</asp:TemplateField>
<asp:boundfield datafield= "Installationid" headertext= "Installationid"
sortexpression= "Installationid"/>
<asp:boundfield datafield= "Completed" headertext= "Completed"/>
<asp:boundfield datafield= "Tid" headertext= "Tid"/>
<asp:boundfield datafield= "Mid" headertext= "mid"/>
<asp:boundfield datafield= "bank" headertext= "bank"/>
<asp:boundfield datafield= "model" headertext= "model"/>
<asp:boundfield datafield= "Barcode" headertext= "Barcode"/>
<asp:boundfield datafield= "Datereq" headertext= "Datereq"
sortexpression= "Datereq"/>
</Columns>
</asp:GridView>
</div>