I have my checkbox for a bool field like so in my view:
=Html.CheckBox("Active", ViewData["Active"] != null ? ViewData["Active"] : (ViewData.Model.Active != null ? ViewData.Model.Active : false)
you can forget the fluff if you like:
=Html.CheckBox("Active", ViewData.Model.Active)
..causes the same problem.
when I try to update my model with:
UpdateModel(vacancy, Request.Form.AllKeys);
I get the object array return with two bool fields. ok, so I understand the need for the hidden field. but im using MVC Beta and I believe the post data is not being processed by UpdateModel correctly. i get this error: System.FormatException "String was not recognized as a valid Boolean." ..when the form posts back sometimes. What i mean by that is that the form works fine, saving true and false states, except when another field on the form is empty. then it complains about the "true,false" value. and that's fine. I understand that a string "true,false" is not a valid bool but why does it complain sometimes and other times work?
EDIT: If someone can even suggest another approach to the UpdateModel() method, I'll look at that. I suspect though that this is something simple I'm missing.
EDIT 2:
This seems to be a known bug in MVC Beta (http://www.codeplex.com/aspnet/WorkItem/View.aspx?WorkItemId=2671&FocusElement=CommentTextBox). Can anyone suggest a workaround?
Solved in ASP.net MVC 1.0
(added the answer so we can eliminate the question from Unanswered
)