Page Display DataGrid

xiaoxiao2021-04-05  623

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 = 1) {if (i == currentpage) {strnav = " i.tostring () ";} Else {strnav =" ";}}}} CurrentPage 10) ";} CurrentPage Next page ";

Literal1.text = strnav; literal2.text = "Total" NumResults.tostring () "Stand Supply Information, Current Show" (START 1) .tostring () "-" TO.TOSTRING () "条, total" pagecount.toString () "page";

转载请注明原文地址:https://www.9cbs.com/read-132163.html

New Post(0)