This is a migrated thread and some comments may be shown as answers.

No parameterless constructor

1 Answer 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chrys
Top achievements
Rank 1
Chrys asked on 25 Apr 2013, 04:08 AM
I have a kendo grid that has editor template for the popup editor. Whenever I call a property directly on the model i.e. @Html.DropDownListFor(model=>model.MyProperty,SomeSelectList) everything Works fine. When I do associated properties on the other hand I get the no parameterless constructor. All of my associated properties specifically have a default constructor. So why am I getting this error when I use @Html.DropDownLIstFor(model=>model.AssociatedPropertyObject.AssociatedPropertyProperty) when both the model and the associatedproperty object have default constructors specified.

This is how my models are set up.
01.public class MyClass
02.{
03.public MyClass()
04.{
05.AssociatedObject=new AssociatedObject();
06.}
07.public AssociatedObject AssociatedObject
08.{get; set;}
09.}
10.public class AssociatedObject
11.{
12.public AssociatedObject()
13.{
14.//do something
15.}
16.}

1 Answer, 1 is accepted

Sort by
0
Accepted
Chrys
Top achievements
Rank 1
answered on 29 Apr 2013, 03:53 PM
1st problem I wasn't using the mvc convention of having selectlist objects no lower in the hierarchy than the controller level. I was adding a selectlist object in my data models (big no no if your working with kendo). Also you must make sure that ever thing that has an object type has a default constructor. What was causing the error form me was properties like this in my model public SelectList MySelectList which SelectList does not have a default constructor instialized.
Tags
Grid
Asked by
Chrys
Top achievements
Rank 1
Answers by
Chrys
Top achievements
Rank 1
Share this question
or