MVC下
后台代码
代码如下:public ActionResult sys(string page){if (page == null){string sql = "select top
* from dingdinfo ORDER BY dingdh desc";ViewData["ds"] = dr
resultSet(sql
"dingdinfo");}if (page != null){int pageSL = Convert
ToInt
(page);string sql = "select top
* from dingdinfo where id not in (select top " + (pageSL
) *
+ " id from dingdinfo order by dingdh desc )ORDER BY dingdh desc";ViewData["ds"] = dr
resultSet(sql
"dingdinfo");}//计算pageCountstring sql
= "select * from dingdinfo";int pageCount = dr
resultCount(sql
"dingdinfo");int Chu = Convert
ToInt
(pageCount /
);int yuS = Convert
ToInt
(pageCount %
);if (pageCount >
){int pageJG = Chu;if (yuS !=
){pageJG = Chu +
;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
ToInt
(ViewData["jg"]);if (count !=
){for (int i =
; i <=count; i++){ %><a href = "#" onclick="Page(<%:i%>)"><%:i%></a><% }}%></td>