熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

ASP無組件分頁實現思路及代碼

2022-06-13   來源: .NET編程 

  MVC下 

後台代碼   代碼如下: public ActionResult sys(string page)  {  if (page == null)  {  string sql = "select top * from dingdinfo ORDER BY dingdh desc";  ViewData["ds"] = drresultSet(sql "dingdinfo");  }  if (page != null)  {  int pageSL = ConvertToInt(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"] = drresultSet(sql "dingdinfo");  }  //計算pageCount  string sql = "select * from dingdinfo";  int pageCount = drresultCount(sql"dingdinfo");  int Chu = ConvertToInt(pageCount / );  int yuS = ConvertToInt(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) {  windowlocation = "/bookIndex/sys/?page=" + id;  }  </script>    HTML代碼   代碼如下: <td>  <% int count =ConvertToInt(ViewData["jg"]);  if (count != )  {  for (int i = ; i <=count; i++)  { %>  <a href = "#" onclick="Page(<%:i%>)"><%:i%></a>  <% }  }%>  </td>   
From:http://tw.wingwit.com/Article/program/net/201311/14123.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.