ASP non-component paging implementation ideas and code

Source: Internet
Author: User

 mvc:  

Background code:    Code as follows: 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.ToInt32 (page);  String sql = "Select" From Dingdinfo WH Ere id "(SELECT top" + (pageSL-1) * + "id" dingdinfo ORDER BY Dingdh Desc) Order BY dingdh Desc ";  V" Iewdata["ds"] = Dr.resultset (sql, "Dingdinfo"); } //Compute pagecount  String SQL1 = "SELECT * from Dingdinfo";   int pagecount = Dr.resultcount (SQL1, "Dingdinfo");  int Chu = Convert.ToInt32 (PAGECOUNT/15);  int yus = Convert.ToInt32 (pagecount%);  if (PageCount >)   {  int pagejg = chu;  if (yus!= 0)   {& nbsp PAGEJG = Chu + 1;  viewdata["JG"] = pagejg; }  else  {  "viewdata["] = JG pagejg; }   Return View(); }    page display:  JS code:    Code as follows: <script type= "Text/javascript" > //Paging   function Page (id) {  window.location = "/bookindex/sys/?page=" + id; }  </script>    HTML Code:    Code as follows: <td>  <% int Count =convert.toint32 (viewdata["JG"]);  if (Count!= 0)   {&NB Sp for (int i = 1; I <=count; i++)   {%>  <a href = "#" onclick= "Page (<%:i%>)" ><%:i%></a >  <%} }%>  </td>   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.