欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net 長(zhǎng)文章通過(guò)設(shè)定的行數(shù)分頁(yè)

 更新時(shí)間:2009年12月06日 22:01:16   作者:  
長(zhǎng)文章通過(guò)設(shè)定的行數(shù)來(lái)實(shí)現(xiàn)分頁(yè)的代碼。
復(fù)制代碼 代碼如下:

public string OutputByLine(string strContent)//通過(guò)設(shè)定的行數(shù)分頁(yè)
{
int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]);//每頁(yè)顯示行數(shù)從CONFIG文件中取出
string lineBreak = ConfigurationManager.AppSettings["lineBreak"];//換行符從CONFIG文件中取出
string lineBreakS = "<" + lineBreak + ">";
string lineBreakE = "</" +lineBreak+">";
strContent = strContent.Replace("\r\n", "");
string[] strLined = strContent.Split(new string[] {lineBreakS, lineBreakE }, StringSplitOptions.RemoveEmptyEntries);//以DIV為換行符
int pageCount = strLined.Length / pageSize;
int pageCountPlus = strLined.Length % pageSize == 0 ? 0 : 1;//非滿頁(yè)
pageCount = pageCount + pageCountPlus;//總頁(yè)數(shù)
int currentPage = 1;//當(dāng)前頁(yè)碼
string displayText = null;
if (Request.QueryString["pageIndex"]!=null) //獲取翻頁(yè)頁(yè)碼
{
currentPage = Convert.ToInt32(Request.QueryString["pageIndex"].ToString());
}
string pageInfo = "";//頁(yè)數(shù)信息
for (int i = 1; i < pageCount+1; i++)
{

if (i==currentPage)
{
pageInfo += " 第" + i + "頁(yè)";
if (pageCount>1)
{
pageInfo += " | ";
}
}
else
{
pageInfo += string.Format("<a href='newshow.aspx?pageIndex={0}' title='翻到第{0}頁(yè)'>{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;
}

相關(guān)文章

最新評(píng)論