Under MVC:
Background code:
Copy codeThe Code is as follows: 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 ");
}
// 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 codeThe Code is as follows: <script type = "text/javascript">
// Pagination
Function Page (id ){
Window. location = "/bookIndex/sys /? Page = "+ id;
}
</Script>
HTML code: Copy codeThe Code is 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>
Final Page effect: