码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-07-03 09:29:14      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:des   art   html   for   代码   htm   

共$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分页时判断首页前一页后一页末页的详细

标签:des   art   html   for   代码   htm   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!