ASP non-component paging implementation ideas and code _ application skills

Source: Internet
Author: User
Under MVC:
Background code:
Copy 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 top * from Dingdinfo where id" (SELECT top "+ (pageSL-1) * +" ID from Dingdinfo order by Dingdh Desc) Order BY dingdh Desc ";
Viewdata["ds"] = Dr.resultset (sql, "Dingdinfo");
}
Calculate 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 ();
}

page display:
JS Code:
Copy Code code as follows:

<script type= "Text/javascript" >
Paging
function Page (ID) {
window.location = "/bookindex/sys/?page=" + ID;
}
</script>

HTML code:
Copy Code code as follows:

<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>

page End Effect:

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.