首页 > 其他 > 详细

NVelocity分页时判断首页前一页后一页末页的详细

时间:2014-07-03 09:28:53      阅读:459      评论:0      收藏:0      [点我收藏+]

共$Data.TotalCount个/$Data.PageNum页
#if($Data.PageNum==1)
<span class="disabled">&nbsp;&lt;&lt;&nbsp;</span>
<span class="disabled">&nbsp;&lt;&nbsp;</span>
#else
<a href="StuList.ashx?PageNum=1">&nbsp;&lt;&lt;&nbsp;</a>
#end


#if($Data.PageNum>1)
<a href="StuList.ashx?PageNum=$Data.FrontPage">&nbsp;&lt;&nbsp;</a>
#end

#foreach($page in $Data.PageData)
#if($page.CurrentNum==$Data.PageNum)
<span class="current">$page.CurrentNum</span>
#else
<a href="$page.href">$page.CurrentNum</a>
#end
#end

#if($Data.PageNum<$Data.PageCount)
#set($NextPage=$Data.PageNum+1)
<a href="StuList.ashx?PageNum=$NextPage">&nbsp;&gt;&nbsp;</a>
#end

#if($Data.PageNum==$Data.PageCount)
<span class="disabled">&nbsp;&gt;&nbsp;</span>
<span class="disabled">&nbsp;&gt;&gt;&nbsp;</span>
#else
<a href="StuList.ashx?PageNum=$Data.PageCount">&nbsp;&gt;&gt;&nbsp;</a>
#end

后台ashx部分代码

int pageNum = 1;
if (context.Request["PageNum"] != null)
{
pageNum = Convert.ToInt32(context.Request["PageNum"]);
}
int totalCount = (int)SqlHelper.ExecuteScalar("select count(*) from T_StuReq where IsDel=‘0‘");
int pageCount = (int)Math.Ceiling(totalCount / 5.0);
DataTable dt = SqlHelper.ExecuteDataTable(@"select * from( select s.requireId , s.Time , c.CName,s.requireAddress,s.requireSex,s.requirePrice,s.SEmail,s.requireInfo,row_number() over (order by s.requireId desc) as num from T_StuReq s left join T_Course c on s.CId=c.CId where s.IsDel=‘0‘)as s
where s.num between @Start and @End",
new SqlParameter("@Start", (pageNum - 1) * 5 + 1),
new SqlParameter("@End", pageNum * 5));
object[] pageData = new object[pageCount];
for (int i = 0; i < pageCount; i++)
{
pageData[i] = new { href = "StuList.ashx?PageNum=" + (i + 1), CurrentNum = (i + 1) };
}
int frontPage = pageNum - 1;
var data = new { Info = "", Person = dt.Rows, TotalCount = totalCount, PageNum = pageNum, PageData = pageData, PageCount = pageCount, FrontPage = frontPage };
string html = NvHelper.RenderHtml("Front/StuList.html", data);

NVelocity分页时判断首页前一页后一页末页的详细,布布扣,bubuko.com

NVelocity分页时判断首页前一页后一页末页的详细

原文:http://www.cnblogs.com/Love1116/p/3818380.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!