MVC下:
后臺(tái)代碼:
復(fù)制代碼 代碼如下:
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");
}
//計(jì)算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();
}
頁(yè)面顯示:
JS代碼:
復(fù)制代碼 代碼如下:
script type="text/javascript">
//分頁(yè)
function Page(id) {
window.location = "/bookIndex/sys/?page=" + id;
}
/script>
HTML代碼:
復(fù)制代碼 代碼如下:
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>
頁(yè)面最終效果:
您可能感興趣的文章:- vue分頁(yè)組件table-pagebar使用實(shí)例解析
- 使用vue.js制作分頁(yè)組件
- 基于Vue.js的表格分頁(yè)組件
- js多功能分頁(yè)組件layPage使用方法詳解
- 第九章之路徑分頁(yè)標(biāo)簽與徽章組件
- 解決JS組件bootstrap table分頁(yè)實(shí)現(xiàn)過程中遇到的問題
- 適用于WebForm Mvc的Pager分頁(yè)組件C#實(shí)現(xiàn)
- yii分頁(yè)組件用法實(shí)例分析
- 分享一個(gè)自己寫的簡(jiǎn)單的javascript分頁(yè)組件
- Vue.js實(shí)現(xiàn)一個(gè)自定義分頁(yè)組件vue-paginaiton