views:

187

answers:

2

hi everyone

i'm really engaged with subsonic but I'm not sure how make it work with paging

i mean how can i get "the page" in a list or how is the best way to managing the total table in my base, page by page

youll see i tried three things:

m02colegio is an class generated from activerecord


IList<m02colegio> loscolegios;
loscolegios = m02colegio.GetPaged(0, 80).ToList();

----------- and:

SubSonic.Schema.PagedList<m02colegio> loscolegios;
loscolegios = m02colegio.GetPaged(0, 80);

----------- and:

var paged = m02colegio.GetPaged(0,80).All<m02colegio>(x=>x.m02ccolnom.Contains(" "));
// 'cause i dont know how to tell it to consider all records
loscolegios = m02colegio.All().ToList();


but after every try i dont get any exception and loscolegios always is NULL

i need to access the records in this manner

so, what is the best way?

how can i get the first page and then how advance among pages??

thanks in advanced

gmo camilo

A: 
public ActionResult Index(int? page)
    {

        if (!validateInt(page.ToString()))
            page = 0;
        else
            page = page - 1;

        if (page < 0) page = 0;

        const int pagesize = 9;

        IQueryable<m02colegio> Mym02colegio = m02colegio.All().Where(x => x.category == "test").OrderBy(x => x.id);

        ViewData["numpages"] = m02colegio.All().Where(x => x.category == "test").OrderBy(x => x.id).Count() / pagesize;
        ViewData["curpage"] = page;


        return View(new PagedList<material>(Mym02colegio, page ?? 0, pagesize));
    }

that is in a MVC sense however it gives you the idea, Index accepts a null or a page number you get all the records then return a pagelist of the records you got.

minus4
A: 

I'm not sure if this is a bug that's been fixed in the current github source or if it's by design but I've found that GetPaged only works with a 1 based index for the first argument. So if you do the following you should find it works as you'd expect:

IList<m02colegio> loscolegios = m02colegio.GetPaged(1, 80);
Adam