点击这里给我发消息 点击这里给我发消息

ASP无组件分页实现思路及代码

添加时间:2013-12-6
    相关阅读: ASP 页面 HTML VC
 

无组件分页不可思议吧,看一看本文的效果就知道了,下面与大家分享下具体的实现,感兴趣的朋友可以参考下哈

MVC下:

后台代码如下:
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");
}
//计算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();
}

页面显示:
JS代码如下:
<script type="text/javascript">
//分页
function Page(id) {
window.location = "/bookIndex/sys/?page=" + id;
}
</script>

HTML代码如下:
<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>

页面最终效果:


咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册