Wednesday, 13 November 2013

ASP.NET MVC ajax.beginform : No parameterless constructor defined for this object

This can also be caused if your Model is using a SelectList, as this has no parameterless constructor:

public class MyViewModel
{
    public SelectList employeeList {get;set;}
}
 
 You'll need to refactor your model to do it a different way if this is the cause. So using an
IEnumerable<SelectListItem> and writing an extension method that
creates the drop down list with the different property definitions:

public class MyViewModel
{
    public IEnumerable<SelectListItem> employeeList { get; set; }
}


Perfect solution !

No comments:

Post a Comment