Note that there are some explanatory texts on larger screens.

plurals
  1. POFormatException: Html.CheckBox(), UpdateModel() and the hidden input
    text
    copied!<p>i have my checkbox for a bool field like so in my view:</p> <pre>=Html.CheckBox("Active", ViewData["Active"] != null ? ViewData["Active"] : (ViewData.Model.Active != null ? ViewData.Model.Active : false)</pre> <p>you can forget the fluff if you like:</p> <pre>=Html.CheckBox("Active", ViewData.Model.Active)</pre> <p>..causes the same problem.</p> <p>when i try to update my model with:</p> <pre>UpdateModel(vacancy, Request.Form.AllKeys);</pre> <p>..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 thats fine. i understand that a string "true,false" is not a valid bool but y does it complain sometimes and other times work? pls help</p> <p><b>EDIT:</b> please, if some1 can even suggest another approach to the UpdateModel() method, i'll look at that. i suspect tho that this is something simple i'm missing.</p> <p><b>EDIT 2:</b> this seems to be a known bug in MVC Beta (<a href="http://www.codeplex.com/aspnet/WorkItem/View.aspx?WorkItemId=2671&amp;FocusElement=CommentTextBox" rel="nofollow noreferrer">http://www.codeplex.com/aspnet/WorkItem/View.aspx?WorkItemId=2671&amp;FocusElement=CommentTextBox</a>). can anyone suggest a workaround?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload