MVC下:
后台代码:
复制代码 代码如下:
public ActionResult sys(string page)
{
if (page == null)
{
string sql = "select top 15 * from dingdinfo ORDER BY dingdh desc";
ViewData["ds"] = dr.resultSet(sql, "dingdinfo");
}
if (page != null)
{
int pageSL = Convert.ToInt32(page);
string sql = "select top 15 * from dingdinfo where id not in (select top " + (pageSL - 1) * 15 + " id from dingdinfo order by dingdh desc )ORDER BY dingdh desc";
ViewData["ds"] = dr.resultSet(sql, "dingdinfo");
}
//计算pageCount
string sql1 = "select * from dingdinfo";
int pageCount = dr.resultCount(sql1,"dingdinfo");
int Chu = Convert.ToInt32(pageCount / 15);
int yuS = Convert.ToInt32(pageCount % 15);
if (pageCount > 15)
{
int pageJG = Chu;
if (yuS != 0)
{
pageJG = Chu + 1;
ViewData["jg"] = pageJG;
}
else
{
ViewData["jg"] = pageJG;
}
}
return View();
}
页面显示:
JS代码:
复制代码 代码如下:
script type="text/javascript">
//分页
function Page(id) {
window.location = "/bookIndex/sys/?page=" + id;
}
/script>
HTML代码:
复制代码 代码如下:
td>
% int count =Convert.ToInt32(ViewData["jg"]);
if (count != 0)
{
for (int i = 1; i =count; i++)
{ %>
a href = "#" onclick="Page(%:i%>)">%:i%>/a>
% }
}%>
/td>
页面最终效果:
您可能感兴趣的文章:- vue分页组件table-pagebar使用实例解析
- 使用vue.js制作分页组件
- 基于Vue.js的表格分页组件
- js多功能分页组件layPage使用方法详解
- 第九章之路径分页标签与徽章组件
- 解决JS组件bootstrap table分页实现过程中遇到的问题
- 适用于WebForm Mvc的Pager分页组件C#实现
- yii分页组件用法实例分析
- 分享一个自己写的简单的javascript分页组件
- Vue.js实现一个自定义分页组件vue-paginaiton