亚音速3.0.0.3 MVC2如何工作的分页Model.Has previousPage不工作 [英] subsonic 3.0.0.3 MVC2 how to work paging Model.HasPreviousPage not working
问题描述
您好,我想有一些很好的传呼我亚音速的项目,我很好的code背后
但我不能找到对的事???观看侧问候传呼的任何信息。
HI i wish to have some nice paging for my subsonic project, i am fine with the code behind however i cant find any information with regards to paging on the view side of things ???
我曾尝试
Model.HasPreviousPage
不过这已经不存在,所以我都出在哪里甚至开始的想法,是有一些隐藏的手册,这个东西的地方,和ActiveRecord的,因为我真的不喜欢不必来问
宁愿有什么事我可以阅读和搜索,但在大多数最新的东西。
but this no longer exists, so am all out of ideas on where to even begin, is there some hidden manual for this stuff somewhere, and activerecord as i really dont like having to come and ask and would rather there was something i could read and search but for the most up to date stuff.
一切我觉得似乎是旧版本的MVC或旧版本两者的亚音速还是差了混合。
everything i find seems to be for old versions of MVC or old versions of subsonic or worse a mix of both.
多AP preciated
much appreciated
推荐答案
好吧,这是我有我自己回来做,我就要AP preciate上,如果这是可行的和可以接受一些意见请:
okay this is what i have done of my own back, i would appreciate some views on if this is viable and acceptable please:
背后的code(控制器)
the code behind (Controller)
public ActionResult Index(int? page)
{
if (!validateInt(page.ToString()))
page = 0;
page = page - 1;
if (page < 0)
page = 0;
const int pagesize = 9;
IQueryable<material> myMaterial = material.All().Where(x => x.category == "Granite").OrderBy(x => x.id);
var mycount = material.All().Where(x => x.category == "Granite").OrderBy(x => x.id).Count();
ViewData["numpages"] = mycount / 9;
ViewData["curpage"] = page;
return View(new PagedList<material>(myMaterial, page ?? 0, pagesize));
}
在HTML
showing page <%=Convert.ToInt32(ViewData["curpage"]) + 1 %> of <%=ViewData["numpages"] %><br />
<%
for (int i = 1; i <= Convert.ToInt32(ViewData["numpages"]); i++)
{
%>
<span><b><%= Html.ActionLink(i.ToString(),"Index","granite",new{page=i},null) %></b></span>
<%
}
%>
跨度仅仅是基本的,但如果这是一个很好的方式,然后我将只是风格我的跨度???
the span is just basic, but if this is a good way then i will just style up my spans ???
我不能得到这个页面不过,不管是什么我似乎得到相同的结果9,现在有点糊涂了!
I cant get this to page though, no matter what i seem to get the same 9 results, am a little confused now !!!
感谢
这篇关于亚音速3.0.0.3 MVC2如何工作的分页Model.Has previousPage不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!