Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No parameterless constructor defined for this object. in kendo grid

I'm using Kendo UI grid on one of my page.

I want to show all users in grid using membership object.

@model IEnumerable<MembershipUser>

@(Html.Kendo().Grid(Model)
.Name("Gridusers")
.Columns(columns =>
{
    columns.Bound(o => o.UserName).Width(100);

})
.Sortable()
.Filterable(filtering => filtering.Enabled(true)))

When I come to this page after getting list of users from controller it is giving error

"No parameterless constructor defined for this object."

It is working fine when I'm using the old Telerik MVC grid but not with Kendo UI grid.

Can any one help me?

like image 201
user1927965 Avatar asked Dec 26 '12 06:12

user1927965


1 Answers

The Kendo UI grid needs the bound model to have a parameterless constructor because it instantiates an instance of it. In your case you could add an empty constructor to the MembershipUser class:

public class MembershipUser
{
     public MembershipUser()
     {
     }

     /* other methods */
}
like image 149
Atanas Korchev Avatar answered Nov 10 '22 00:11

Atanas Korchev