Error when paging using PagedList with ListDinamyc

0

I'm trying to paginate a WebGrid using PagedList but a conversion error occurs:

  

Additional information: Can not implicitly convert type   'PagedList.PagedList' in   'System.Collections.Generic.List'

I do not know if it occurs because the variable dns is of type List<dynamic> as shown below:

ViewBag.Columns = columns;                    
                var dns = new List<dynamic>();
                dns = Util.DataTableParaDynamic.ConverterDtParaList(dt);
                int paginaTamanho = 15;
                int paginaNumero = (page);
                ViewBag.Total = dns.ToPagedList(paginaNumero, paginaTamanho); 

It is not necessary to use PagedList, I can use any other medium that pagination and works under these conditions.

    
asked by anonymous 12.06.2017 / 21:13

1 answer

0

No need to use PagedList , just use Skip and Take that works perfectly:

dns = Util.DataTableParaDynamic.ConverterDtParaList(dt);
                if (dns.Count > pageNumber)
                {
                    ViewBag.Total = dns.Skip((pageSize - 1) * pageNumber)
                                        .Take(pageSize)
                                        .ToList();
                }else
                {
                    ViewBag.Total = dns;
                }
    
13.06.2017 / 11:34