asp.net long article through the set number of lines pagination _ practical skills

Source: Internet
Author: User
Copy Code code as follows:

public string Outputbyline (string strcontent)//paging by set number of rows
{
int pageSize = Int. Parse (configurationmanager.appsettings["pageSize"])//page number of rows displayed from config file
String linebreak = configurationmanager.appsettings["LineBreak"];//newline character removed from config file
String linebreaks = "<" + linebreak + ">";
String linebreake = "</" +linebreak+ ">";
Strcontent = Strcontent.replace ("\ r \ n", "");
string[] strlined = Strcontent.split (new string[] {linebreaks, linebreake}, Stringsplitoptions.removeemptyentries); Take Div as line feed
int pagecount = strlined.length/pagesize;
int pagecountplus = strlined.length% pageSize = 0? 0:1;//not full page
PageCount = pagecount + pagecountplus;//Total pages
int currentpage = 1;//Current page number
string displayText = null;
if (request.querystring["PageIndex"]!=null)//Get page number
{
CurrentPage = Convert.ToInt32 (request.querystring["PageIndex"). ToString ());
}
String pageInfo = "";//Page information
for (int i = 1; i < pagecount+1; i++)
{

if (i==currentpage)
{
PageInfo + + i + "page";
if (pagecount>1)
{
PageInfo + = "|";
}
}
Else
{
PageInfo = = String. Format ("<a href= ' newshow.aspx?pageindex={0} ' title= ' turn to {0} page ' >{0}" | </a> ", i);
}
}
Labpagenumber.text = PageInfo;
for (int i = (currentPage-1) *pagesize i < currentpage*pagesize&&i<strlined.length; i++)
{
DisplayText + + "<div>" + strlined[i] + "</div>";
}
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.