Reputation: 71
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?
Upvotes: 6
Views: 2269
Reputation: 21
It should also be clear that Telerik is going to construct an instance of the bound classes as well as that classes members. For example if your grid is bound to Dogs ...
public class Dog {
public DogKind Kind { get; set; }
public Dog() {
}
}
then your "DogKind" class also has to have a default constructor.
Upvotes: 0
Reputation: 30671
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 */
}
Upvotes: 10