Added: The JSON-based Ajax brushless new paging has been done, please refer to the http://www.cnblogs.com/zhouzhaokun/archive/2011/08/24/2151866.html
I was going to create a JSON-based Ajax paging effect today. When I got up early in the morning, I went to the garden to find food .. We can see the implementation of the page splitter abbreviated by kwklover. Http://www.cnblogs.com/kwklover/archive/2006/04/21/381832.html I made some modifications on his basis, but still not very perfect!CodeAs follows:
// Http://www.cnblogs.com/kwklover/archive/2006/04/21/381832.html protected void page_load (Object sender, eventargs e) {If (request ["page"] = NULL | request ["page"] = "") buildpager (10000, 1, 10); else buildpager (10000, convert. toint32 (request ["page"]), 10 );} /// <summary> /// create and display the page splitter /// </Summary> /// <Param name = "totalrecords"> total number of pages </param> /// <Param name = "currentpage"> current page number </param> /// <para M name = "pagesize"> page size </param> private void buildpager (INT totalrecords, int currentpage, int pagesize) {int alter = 4; int startpage = 1; int endpage = currentpage + alter; int totalpages = This. calculatetotalpages (totalrecords, pagesize); If (currentpage> Alter) {startpage = currentpage-alter;} If (endpage> totalpages) {endpage = totalpages ;} string strtemp = @ "<a Title = '{0}' href = 'defa Ult. aspx? Page = {1} '> {2} </a> "; stringbuilder sb = new stringbuilder (" "); If (currentpage! = Startpage) {If (currentpage> startpage) {sb. append (string. format (strtemp, 1, 1, "Homepage"); sb. append (string. format (strtemp, currentpage-1, currentpage-1, "Previous Page") ;}}for (INT I = startpage; I <= endpage; I ++) {If (currentpage = I) {sb. append ("<font color = Red>" + I + "</font>");} else {sb. append (string. format (strtemp, I, I, "[" + I + "]") ;}} if (currentpage! = Endpage) {sb. append (string. format (strtemp, currentpage + 1, currentpage + 1, "Next"); sb. append (string. format (strtemp, totalpages, totalpages, "Last page");} This. ltlshowpager. TEXT = sb. tostring ();} /*** // <summary> // calculate the total number of pages /// </Summary> /// <Param name = "totalrecords"> total number of records </Param >/// <Param name = "pagesize"> Number of records per page </param> private int calculatetotalpages (INT totalrecords, int pagesize) {int totalpagesavailable; totalpagesavailable = totalrecords/pagesize; // Since the integer division of C # rounds all the remainder to 0, therefore, you need to determine whether to add 1 If (totalrecords % pagesize)> 0) totalpagesavailable ++; return totalpagesavailable ;}
Paste the code of the page sharer first. Later I will upload a JSON-based Ajax paging... Do not spray ,:-)... Welcome