ASP. Mvc:pagedlist + View Model

Source: Internet
Author: User

To pass view model with Pagedlist:


1. Controller action must use HttpGet and use View Model as action parameter

Public ActionResultIndex (Userindexmodelmodel)

2. The action return the view model with Pagingmetadata

model. Pagingmetadata =New staticpagedlist<Userindexitem> (model. Users, model. Page.value, Default_page_size, total);

return model;

Pagingmetadata is defined in View Model like below:

Public ipagedlistPagingmetadata {Get; Set; }


3. In view with the Pager like below to pass data needed back to action by View model:

@Html. Pagedlistpager (New staticpagedlist<report.areas.tis.models.Userindexitem> (model.users, Model.pagingmetadata),

page = url.action ("Index", new routevaluedictionary () {

{ "page", page},

{ "filtername", model.filtername},

{ "Filterdatebegin", Model.filterdatebegin},

{ "filterdateend", model.filterdateend},

{ "Filtersiteid", Model.filtersiteid},

{ "filterposition", model.filterposition},

{ "filterupdated",false}}),

pagedlistrenderoptions. Classic)

Reference:

Http://stackoverflow.com/questions/14258212/mvc-posting-ipagedlist

Http://czetsuya-tech.blogspot.co.id/2011/05/mvc3-dynamic-search-paging-using.html#.VkHD8TahfIU

Https://github.com/TroyGoode/PagedList

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

ASP. Mvc:pagedlist + View Model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.