asp.net - mvc pagedlist page number not incrementing -
i'm using mvc 5 along pagedlist.mvc 4.5.0.0, have data coming , displaying on table, along pager controls showing up. when click next though, pager continues send page = 1 function, see while debugging.
my page has:
<div class="pagedlist" data-otf-target="#contractlist"> @html.pagedlistpager(model, page => url.action("index", new { page }), pagedlistrenderoptions.minimalwithitemcounttext) </div>
my method sends data action is
public ipagedlist<contractviewmodel> getallcontracts(int page = 1) { var lstcontractviewmodel = new list<contractviewmodel>(); using (contractrepository contractrepos = new contractrepository(new unitofwork())) { var activecontractlist = contractrepos.all.orderbydescending(x => x.id); foreach (var activecontract in activecontractlist) { mapper.createmap<domainclasses.activecontract, activecontractviewmodel>().formember(dest => dest.contractormodel, opts => opts.ignore()); mapper.assertconfigurationisvalid(); lstcontractviewmodel.add(mapper.map<activecontractviewmodel>(activecontract)); } } return lstcontractviewmodel.topagedlist(page, 40); }
and controller's action is
public actionresult index() { var contracts = activeaccountcontroller.getallcontracts(); return view(contracts); }
as said comes fine 1st page, when getallcontracts method called, debugger shows page = 1. paging returning 1st page of results. have on 2500 records, other data there, pager shows that, pager says "showing items 1 through 40 of 2546."
@html.pagedlistpager(model, page => url.action("index", new { page }), pagedlistrenderoptions.minimalwithitemcounttext)
try set new{page = somevalue} , send in param.
public actionresult index(int page) public ipagedlist<contractviewmodel> getallcontracts(int page = 1)
this means page default 1 if no other param applied.
var contracts = activeaccountcontroller.getallcontracts(page);
for more info read https://github.com/troygoode/pagedlist
Comments
Post a Comment