asp.net 긴 문장 설정된 줄 수를 통해 페이지 나누기

1831 단어
 
  
public string OutputByLine(string strContent)//
{
int pageSize = int.Parse(ConfigurationManager.AppSettings["pageSize"]);// CONFIG
string lineBreak = ConfigurationManager.AppSettings["lineBreak"];// CONFIG
string lineBreakS = "";
string lineBreakE = "" +lineBreak+">";
strContent = strContent.Replace("\r
", "");
string[] strLined = strContent.Split(new string[] {lineBreakS, lineBreakE }, StringSplitOptions.RemoveEmptyEntries);// DIV
int pageCount = strLined.Length / pageSize;
int pageCountPlus = strLined.Length % pageSize == 0 ? 0 : 1;//
pageCount = pageCount + pageCountPlus;//
int currentPage = 1;//
string displayText = null;
if (Request.QueryString["pageIndex"]!=null) //
{
currentPage = Convert.ToInt32(Request.QueryString["pageIndex"].ToString());
}
string pageInfo = "";//
for (int i = 1; i < pageCount+1; i++)
{

if (i==currentPage)
{
pageInfo += " " + i + " ";
if (pageCount>1)
{
pageInfo += " | ";
}
}
else
{
pageInfo += string.Format("{0} |",i);
}
}
labPageNumber.Text = pageInfo;
for (int i = (currentPage-1)*pageSize; i < currentPage*pageSize&&i{
displayText += "
" + strLined[i] + "
";
}
return displayText;
}

좋은 웹페이지 즐겨찾기