A self-reconstructed page

Source: Internet
Author: User
/// <Summary> /// paging control (Wu) /// </Summary> /// <Param name = "recordcount"> Number of records </param> /// <Param name = "curpage"> current page </Param> /// <Param name = "pagesize"> how many pieces of data per page </param> /// <Param name = "actionurl"> paging jump link </param>/ // <Param name = "argname"> name of the parameter on the current URL page </param> // <returns> </returns> Public static string topagehtml (INT recordcount, int curpage, int pagesize, string actionurl, string argname) {stringbuilde R sb = new stringbuilder (); If (recordcount> 0) {int pagesum = recordcount/pagesize; // total page number if (recordcount % pagesize> 0) {// calculate the remainder pagesum = pagesum + 1;} int pagemaxsum = 3; // If (curpage <1) curpage = 1; if (curpage> pagesum) curpage = pagesum; sb. appendline ("<Div class = \" Liem-bottom \ "> <ul class = \" tunepage \ "> \ r \ n "); // previous page if (1 = curpage) {// sb. appendline ("<li> <A> Previous Page </A> </LI> ");} else {sb. appendformat ("<li> <a href = \" "+ getanchorurl (curpage-1, actionurl, argname) + "\"> previous page </a> </LI> ");} var startindex = 1; var endindex = pagesum; If (pagesum> pagemaxsum * 2 + 1) {If (curpage-pagemaxsum> 0) {If (curpage + pagemaxsum <pagesum) {startindex = curpage-pagemaxsum; endindex = curpage + pagemaxsum ;} else {startindex = pagesum-pagemaxsum * 2 ;}} els E {endindex = pagemaxsum * 2 + 1 ;}} if (pagesum> 1) {If (startindex. equals (2) {sb. appendline ("<li> <a href = \" "+ getanchorurl (1, actionurl, argname) +" \ "> 1 </a> </LI> "); endindex --;} else if (startindex> 2) {sb. appendline ("<li> <a href = \" "+ getanchorurl (1, actionurl, argname) +" \ "> 1 </a> </LI> "); SB. appendline ("<li>... </LI> ") ;}// page number for (VAR I = startindex; I <= endindex; I ++) {If (curpag E = I) {sb. appendline ("<li> <a class = \" Current \ ">" + curpage + "</a> </LI>");} else {sb. appendline ("<li> <a href = \" "+ getanchorurl (I, actionurl, argname) + "\"> "+ I +" </a> </LI> ") ;}} if (endindex <pagesum-1) {sb. appendline ("<li>... </LI> "); sb. appendline ("<li> <a href = \" "+ getanchorurl (pagesum, actionurl, argname) + "\"> "+ pagesum +" </a> </LI> ");} else if (endindex <pagesum) {sb. appendline ("<li> <a href = \" "+ getanchorurl (pagesum, actionurl, argname) + "\"> "+ pagesum +" </a> </LI> ") ;}// next page if (curpage = pagesum | pagesum = 0) {// sb. appendline ("<li> <A> next page </a> </LI>");} else {sb. appendline ("<li> <a href = \" "+ getanch Orurl (curpage + 1, actionurl, argname) + "\"> next page </a> </LI> ");} sb. appendline ("\ r \ n </ul> </div>");} return sb. tostring ();} Private Static string getanchorurl (INT curpage, string actionurl, string argname) {If (actionurl. indexof ("? ")> 0) {return string. format ("{0} & {1} = {2}", actionurl, argname, curpage);} return string. format ("{0 }? {1 }={ 2} ", actionurl, argname, curpage );}
View code
Create procedure usp_fenye @ pageindex int, @ pagecount Int = 10, @ pagetotalcount int outputasbegin -- calculate the total number of pages declare @ totaldata int; Set @ totaldata = (select count (*) from T) set @ pagetotalcount = ceiling (@ totaldata * 1.0/@ pagecount); -- obtain the data select * from (select *, num = row_number () over (order by ID) from T) as t where T. num between @ pagecount * (@ pageInde-1) + 1 and @ pagecount * @ pageindex; endgo
View code

Write a stored procedure on a page without explanation. People with a basic understanding should understand it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.