C# 带偏移量自定义分页方法
来源:互联网 发布:免费网络图绘制软件 编辑:程序博客网 时间:2024/05/16 15:23
/// <summary> /// 带偏移量自定义分页方法 /// </summary> /// <param name="PageSize">每页条数</param> /// <param name="CurrentPage">当前页</param> /// <param name="TotalCountRecord">总条数</param> /// <param name="where">条件</param> /// <returns></returns> public string BuildPagers(int PageSize, int CurrentPage, int TotalCountRecord,string where) { //偏移量 int Step = 5; int LeftNum = 0;//左值 int RightNum = 0; string PageUrl = Request.FilePath; int PageCount = (int)Math.Ceiling((double)(TotalCountRecord) / PageSize); //总页数 //当前页-步长 <1 则作值=1 if (CurrentPage - Step < 1) { LeftNum = 1; } else { LeftNum = CurrentPage - Step; } if (CurrentPage + Step > PageCount) { RightNum = PageCount; } else { RightNum = CurrentPage + Step; } StringBuilder OutPut = new StringBuilder(); string strUrl = ""; for (int i = LeftNum; i <= RightNum; i++) { if (i == CurrentPage) { OutPut.Append("<font style='margin-left:3px;' color=red>"); OutPut.Append(i.ToString()); OutPut.Append("</font>"); } else { OutPut.Append("<a style='margin-left:3px;' href='"); OutPut.Append(PageUrl); OutPut.Append("?" + where + "&page="); OutPut.Append(i.ToString()); // OutPut.Append(strUrl); OutPut.Append("'>"); OutPut.Append(i.ToString() + " "); OutPut.Append("</a>"); } } if (CurrentPage > 1) { OutPut.Insert(0, string.Format("<a href='{0}?" + where + "&page={1}{2}'>上一页</a>", PageUrl, (CurrentPage - 1), strUrl)); } if (CurrentPage < PageCount) { OutPut.Append("<a href='"); OutPut.Append(PageUrl); OutPut.Append("?" + where + "&page="); OutPut.Append(+CurrentPage + 1); OutPut.Append(strUrl); OutPut.Append("'>下一页</a></li>"); OutPut.Append("总记录数:<font color='red'>" + TotalCountRecord + "</font> 总页数:<font color='red'>" + PageCount + "</font>"); } return OutPut.ToString(); }
private void Bind(int Page,string where) { str = BuildPagers(16, Page, GoodsFunBLL.GetGoodsListCount(where), where); this.DataGoodsList.DataSource = GoodsFunBLL.GetGoodsByTypeIdList(16, Page,where); this.DataGoodsList.DataBind(); }
0 0
- C# 带偏移量自定义分页方法
- MySQL分页查询偏移量问题
- C# 处理 google map 经纬度偏移量
- 获取struct成员偏移量的方法
- 求结构体的偏移量方法
- 偏移量
- 偏移量
- 大偏移量下Redis、MongoDB分页/排名性能比较
- 大偏移量下Redis、MongoDB分页/排名性能比较
- 大偏移量下Redis、MongoDB分页/排名性能比较
- 大偏移量下Redis、MongoDB分页/排名性能比较
- 【带偏移量的并查集】:poj***,Butterfly
- POJ 1988 带偏移量的并查集
- poj1182 食物链 带权并查集 偏移量
- c语言 获取结构体成员偏移量方法
- 计算结构体中偏移量的方法
- 查表指令中计算偏移量的简便方法
- mysql limit查询优化方法(offset偏移量)
- D3DXCreateFont”: 函数不接受 12 个参数
- java.io.IOException: open failed: EACCES (Permission denied) 问题解决
- JS正则表达式验证账号、手机号、电话、邮箱、货币
- leetcode java unique binary search tree
- Android 数字签名学习笔记
- C# 带偏移量自定义分页方法
- mysql基础知识回顾
- Generate Parentheses
- oracle游标详解
- Adobe Reader退出Linux
- 百度地图 iOS SDK - 新版本上线,支持iOS8、arm64、iPhone6
- 你的API有“状态”吗?
- java中的链表和树的节点
- Letter Combinations of a Phone Number