Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7554165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:15:56+00:00 2026-05-30T11:15:56+00:00

As per : MVC3 Model binding pagedlist to ViewModel with custom EditorTemplate and Partial

  • 0

As per : MVC3 Model binding pagedlist to ViewModel with custom EditorTemplate and Partial View

See above question for code snippets

The problem i am having now surrounds binding the custom IPagedList collection. The model binder attempts to bind the values to the property on the ViewModel but is unable to create an instance of the interface (no suprises there).

So how can i bind values back to my viewModel by instantiating a concrete PagedList class when the values are bound? As i understand it the IEnumerable binder does this for a List or similar derivitive, so how can i do this for my custom class/interface?

Do i need a custom model binder for this? If so any information or code tips on this is great!

Any help greatly appreciated thanks.

Update:

Changing the ViewModel to include an overriden default constructor which initialises the Interface like so:

public class RequestCreateViewModel : ViewModelBase
{
    public IPagedList<CreateRequestModel> PagedList { get; set; }

    public RequestCreateVieWModel()
    {
        PagedList = new PagedList<RequestCreateModel>(new List<RequestCreateModel>(), new PagingOptions());
    }

.. appears to allow the default model binder to work as per my comment. But it doesnt seem like a great solution, mainly because im needing to infer new object parameters for the PagedList object each time a ViewModel is created. Am i needlessly worrying?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T11:15:58+00:00Added an answer on May 30, 2026 at 11:15 am

    Look at the source for DefaultModelBinder.cs in the ASP.NET MVC project on Codeplex. The comment in the BindComplexModel sums it all up:

    // special-case IDictionary<,> and ICollection<>
    

    If the MVC framework special cases those types then you will need to create a custom model binder for your type. But the solution you provide works…why? Your type is does not implement the ICollection or IDictionary special cases. The default code path calls the default constructor for a model type:

    // fallback to the type's default constructor
    return Activator.CreateInstance(typeToCreate);
    

    Your default constructor creates the type you need. Therefore, no error. No default constructor, no object instance and as you have pointed out, you get an error.

    You asked for more ideas. How about leaving what you have. It works. Writing a custom model binder would just be more work at this point. More code to accomplish the same thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Per this question (see comments near the bottom), I was wondering if anyone knows
I'm using the Unity MVC3 code at http://unitymvc3.codeplex.com/ to have a NHibernate session per
Per the Java documentation, the hash code for a String object is computed as:
Per a great answer from another question I have begun mounting global resources (css/js/images)
As per my understanding stateless session beans are used to code the business logic.
I am building wizard step demo application with MVC3 and using razor view engine
What I wants for HTML Output <select name=model binding name> <option value=44 data-object=jsonencoded object>122
I am trying to build a sample for myself using MVC3, Razor view engine
I'm using RazorGenerator to unit test my Razor/MVC3 per David Ebbo's post here http://blog.davidebbo.com/2011/06/unit-test-your-mvc-views-using-razor.html
In MVC3 application I have my custom implementation of IPrincipal. I want to register

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.