No parameterless constructor defined for this object

Jan 28, 2013 at 9:26 AM

I am new to mvc and trying out the Datagrid.

When debugging, I get the page loading and displaying the data but when I click on the "page 2" link or the "next" arrow I get :

No parameterless constructor defined for this object

No break points in the code seem to highlight where the problem might be occuring and the message appears so generic as to make it difficult to establish what might be causing the problem.

any pointers would be helpful.

Coordinator
Jan 28, 2013 at 12:58 PM

Probably the objects you display in the grid have no constructor with 0 parameters, so the model binder is not able to create an istance of it (because it have no idea of which paranmeters to pass to the constructor. Just define a parameterless constructor in the class definition!

All objects that you want to read back when the page is posted back must have a parameterless constructor. 

Jan 28, 2013 at 2:45 PM

Hi

thanks. Resolved.