views:

830

answers:

1

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 ???

i have tried

Model.HasPreviousPage

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.

everything i find seems to be for old versions of MVC or old versions of subsonic or worse a mix of both.

much appreciated

+1  A: 

okay this is what i have done of my own back, i would appreciate some views on if this is viable and acceptable please:

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));

    }

the 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 ???

I cant get this to page though, no matter what i seem to get the same 9 results, am a little confused now !!!

thanks

minus4
it does page, i must be sniffing way too much glue :-)so how is, is this okay?? is this making good usage of MVC ????
minus4