ASP无组件分页实现思路及代码_ASP教程-查字典教程网
ASP无组件分页实现思路及代码
ASP无组件分页实现思路及代码
发布时间:2015-06-05 来源:查字典编辑
摘要:MVC下:后台代码:代码如下:publicActionResultsys(stringpage){if(page==null){string...

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代码: 代码如下: % int count =Convert.ToInt32(ViewData["jg"]); if (count != 0) { for (int i = 1; i i++) { %a href = "#" onclick="Page()"%:i%/a% } }%/td

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新ASP教程学习
    热门ASP教程学习
    编程开发子分类