Asp.net long article pagination by the set number of rows

Source: Internet
Author: User

CopyCode The Code is as follows: Public String outputbyline (string strcontent) // pagination by setting the number of rows
{
Int pagesize = int. parse (configurationmanager. etettings ["pagesize"]); // retrieve the number of lines displayed on each page from the config file
String linebreak = configurationmanager. receivettings ["linebreak"]; // The linefeed is extracted from the config file.
String linebreaks = "<" + linebreak + "> ";
String linebreake = "</" + linebreak + "> ";
Strcontent = strcontent. Replace ("\ r \ n ","");
String [] strlined = strcontent. Split (New String [] {linebreaks, linebreake}, stringsplitoptions. removeemptyentries); // use Div as the line break
Int pagecount = strlined. Length/pagesize;
Int pagecountplus = strlined. Length % pagesize = 0? 0: 1; // non-full page
Pagecount = pagecount + pagecountplus; // total number of pages
Int currentpage = 1; // current page number
String displaytext = NULL;
If (request. querystring ["pageindex"]! = NULL) // obtain the page number
{
Currentpage = convert. toint32 (request. querystring ["pageindex"]. tostring ());
}
String pageinfo = ""; // page number
For (INT I = 1; I <pagecount + 1; I ++)
{

if (I = currentpage)
{< br> pageinfo + = "page" + I + ";
If (pagecount> 1)
{< br> pageinfo + = "|";
}< BR >}< br> else
{< br> pageinfo + = string. format (" {0} | ", I );
}< BR >}< br> labpagenumber. TEXT = pageinfo;
for (INT I = (currentPage-1) * pagesize; I {< br> displaytext + = "

" + strlined [I] + "
";
}< br> return displaytext;
}

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.