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;
}