ASP.NET分页技术
来源:互联网 发布:黑色沙漠城镇优化 编辑:程序博客网 时间:2024/05/16 19:46
自己在做网站时经常使用的一个分页程序,希望大家指点!
public static StringBuilder PageBtn(int currentPage, int numInOneLine, string url, PagedDataSource pds)//返回索引字符串,numInOneLine为每行索引的个数,currentPage为当前页;
{
StringBuilder sb = new StringBuilder();
int currentLine; //当前索引行
if (currentPage % numInOneLine != 0)//判断当前页是否为每行索引的个数的整数倍;
{
currentLine= currentPage / numInOneLine + 1;
}
else
{
currentLine=currentPage / numInOneLine;
}
//添加上一索引行连接
if (currentLine == 1)
{
sb.Append("<< ");
}
else
{
sb.Append("<a href='");
sb.Append(url);
sb.Append("?currentPage=");
sb.Append(Convert.ToString((currentLine-1)*numInOneLine));
sb.Append("'><<</a> ");
}
//添加页码索引
for (int i = 1; i <= numInOneLine; i++)
{
//<a href="Datalist.aspx" style="color:Red">[]</a>
if ((currentLine - 1) * numInOneLine + i<=pds.PageCount)//判断页码是否出界;
{
if ((currentLine - 1) * numInOneLine + i == currentPage)//判断索引页码是否为当前页
{
sb.Append(" <font style='color:Red; text-decoration: none;'>");
sb.Append(currentPage.ToString());
sb.Append("</font> ");
}
else
{
sb.Append("<a href='");
sb.Append(url);
sb.Append("?currentPage=");
sb.Append(Convert.ToString((currentLine - 1) * numInOneLine + i));
sb.Append("'>[");
sb.Append(Convert.ToString((currentLine - 1) * numInOneLine + i));
sb.Append("]</a> ");
}
}
}
int totalLine;//定义总索引行数
if (pds.PageCount % numInOneLine != 0)//判断总页数是否为每行索引的个数的整数倍;
{
totalLine = pds.PageCount / numInOneLine + 1;
}
else
{
totalLine = pds.PageCount / numInOneLine;
}
//添加下一索引行
if (currentLine == totalLine)
{
sb.Append(">>");
}
else
{
sb.Append("<a href='");
sb.Append(url);
sb.Append("?currentPage=");
sb.Append(Convert.ToString(currentLine * numInOneLine + 1));
sb.Append("'>>></a>");
}
return sb;
}
- ASP.NET分页技术
- Asp.net:DataList分页技术
- Asp.net:DataList分页技术
- Asp.net:DataList分页技术
- Asp.net:DataList分页技术
- ASP.NET分页显示技术
- 关于asp.net分页技术实现
- ASP.NET查询分页技术:实现Web数据分页浏览
- ASP.NET查询分页技术:实现Web数据分页浏览
- 用asp.net轻松打造功能完备的分页技术!!!!
- 用asp.net轻松打造功能完备的分页技术!!!!
- 用asp.net轻松打造功能完备的分页技术!!
- ASP.NET 2.0 分页技术之使用PagedDataSource篇
- 用asp.net轻松打造功能完备的分页技术!!!!
- Asp.net用ajax技术实现无刷新分页
- ASP.NET大数据量分页技术的初步体验技巧
- ASP分页技术源码
- ASP分页技术源码
- 如何在英文Ubuntu下输入中文
- 理解对象clone及数组clone
- ASP.NET2.0_缓存
- 看“不要让集群存储成为被忽视的角落”总结
- 文字竖排工具BY烟锁重楼
- ASP.NET分页技术
- 再次光临草根鸡翅!
- C#调用快捷方式打开相应的应用程序-以解决
- OO五大原则
- String.Compare的用法
- 我欲成佛
- 财务会计1---交易分析
- 语音识别系统
- Men are from Mars, Women are from venus