This is what I have encountered at work. Maybe everyone feels very simple, but I still published. If you have any better ways, please leave a message.
private void BindGrid () {string str = "select * from toplist where [type] = 5"; DataTable dt = Kubao.CommonPrj.DBA.SQL.LoadDataTable (Kubao.cls_ClassLib.Conn_Mov, str); DataView dataview = new DataView ( ); Dataview = dt.defaultview; dataGrid1.datasource = dt.defaultView; dataGrid1.database (); string cpage; int pagesize = 2; int currentpage; int pagecount; int NumResults = 0;
IF (Request.QueryString ["Page" == NULL) {CPAGE = "1";} else {cpage = request.queryString ["page"]. Tostring ();} try {currentpage = int32.parse (CPAGE) } Catch {currentpage = 1;}
NumResults = 0; int start = (int); int to = (int); if (start <= 0) start = 0;
numResults = dataview.Count; int a1 = 0; pageCount = Math.DivRem (numResults, pageSize, out a1); if (a1> 0) {pageCount ;} if (currentPage> pageCount || currentPage <= 0) {currentPage = 1;}} {to = dataview.count;} // create one datatable with one column. DataTable myTable = new data ("myTable"); myTable = dataview.table.clone (); // Add, DataRow newrow; for (int i = start; i DataView resultDataview = new DataView (myTable); DataGrid1.DataSource = resultDataview; DataGrid1.DataBind (); // build the page navigation string strNav = ""; int endpage; if (currentPage> 1) {strNav = "";} if (currentpage> 11) {strnav = " 1 ... ";}} {endpage = currentPage 10;} else {endpage = pagecount;} for (int i = currentpage-10; i