HTML:
Code Replication-Running
<table id= "DataList" ></table>
JQuery Easyui:
Code Replication-Running
$ (' #dataList '). DataGrid ({
title: ' Paging Data ', //title
iconcls: ' Icon-save ', //Table icon
width:500, / /table Width
height:300,// table height
pagesize:15,//per page display quantity
pagelist: [15, 30, 45],///You can set the list URL for the number of record bars per page
: '/ Home/getlist ',//MVC controllers address
sortname: ' ID ',// field to sort
sortOrder: ' desc ',// sorting rules
Singleselect:true, //Only select single line
pagination:true //Here must be set to true
});
var p = $ (' #datList '). DataGrid (' Getpager ');
P.pagination ({
beforepagetext: ' First ', the kanji displayed before//page text box
afterpagetext: ' pages total {pages} ',
displaymsg: ' The {from}-{to} record is currently displayed ( total} record '
}];
C #:
Code Replication-Running
Background database Paging public Jsonresult getlist () {try {string rows = R equest["Rows"]. ToString (); Gets the number of rows from the DataGrid string page = request["page". ToString (); Get the page number//current page int intpage = int from the DataGrid. Parse ((page = null | | | page = = "0")?
"1": page); The number of bars per page int = Int. Parse (rows = NULL | | rows = "0")?
"Ten": rows);
The start record for each page is 1 page two for number +1 int start = (intPage-1) * number; var TB = dt.listpage (number, start);
DT For Models Datacontext,listpage is a stored procedure var jsonmap = new dictionary<string, object> ();
Jsonmap.add ("Total", count ());
Jsonmap.add ("Rows", TB);
Return Json (Jsonmap, jsonrequestbehavior.allowget);
catch {return null;
}} private int count () {try {var TB = from DB in dt.table
Select DB; Return TB.
Count ();
catch {return 0;
}
}
SQL stored procedures:
Code Replication-Running
CREATE PROCEDURE listpage
@number int,
@start int
as
select Top (@number) * FROM table where (ID no in (SE Lect Top (@start) ID from table order BY id DESC) desc