4

I have a form with a select box on it.

The linq entity has a selectList as a public property on it.

I'm currently excluding it from the entity like this

[Bind(Exclude = "taskDeadlineTime")]

I now want to add a second drop down, and I'm getting this error when I try to UpdateModel()

No parameterless constructor defined for this object.

Is it right that I should be adding this new property to the bind exclude list?

If so how do I add more than one property to the list?

Jason Berkan
  • 8,734
  • 7
  • 29
  • 39
Chris Barry
  • 4,564
  • 7
  • 54
  • 89
  • duplicate? : http://stackoverflow.com/questions/1355464/asp-net-mvc-no-parameterless-constructor-defined-for-this-object/ – Martin Sep 01 '10 at 19:06
  • I don't think so, I haven't really changed the controller. Also it works fine if I remove the instance of the select list from the view. If the bind exclude works fine, why can't I just extend it out for multiple properties? Do I just need to know the syntax for doing that? – Chris Barry Sep 01 '10 at 19:15

1 Answers1

9

Exclude takes a comma separated list of property names, just add another.

Complete Docs:

http://msdn.microsoft.com/en-us/library/system.web.mvc.bindattribute.aspx

John Farrell
  • 24,673
  • 10
  • 77
  • 110
  • This doesn't work, [Bind(Exclude = "taskDeadlineTime", "taskStartTime")] error named attribute argument expected, please can you show me the exact syntax, I have tried quite a few? – Chris Barry Sep 01 '10 at 20:02
  • 2
    [Bind(Exclude = "Prop1, Prop2, Prop3, ...")] – Levi Sep 01 '10 at 21:41
  • Yep, thats it, I tried so many different things, grouping strings inside a single literal caught me out. The correct was [Bind(Exclude = "taskDeadlineTime,taskStartTime")] – Chris Barry Sep 02 '10 at 09:08