Wednesday, 15 January 2014

asp.net mvc - The string was not identified as a valid Boolean string -


I have a page where I list the checker called timerange 1, timerange 2, timerange 2, and i Generate in the loop like this:

  for <%> (int present day = 1; current day and lieutenant; 7; current day ++) ...... & lt; % = Html.CheckBox ("timeline" + current day. String (), incorrect)%>  

I work fine to post the form, then I did not recognize a "string as a valid boolean string."

Obviously the problem is that I name the checkbox.

Is there some sort of way to decide? Let me name them 1-7, it's like a big schedule, where you choose which time should be available.

Try the assistants without:

   & Lt; Input type = "checkbox" name = "deadline  & gt; / & Gt; & Lt;%}% & gt;  

HTML helpers receive their values:

  1. See data.modelstate ["control name"]. Value.RawValue .
  2. The value parameter has been passed to the HTML support system.

They also generate hidden input fields in addition to the checkboxes. Therefore, sometimes depending on context you may also end up with markup like this:

  & lt; Input type = "checkbox" name = "timerange1" value = "some value, wrong" />  

And when you post a form, the data binder will be unable to convert the value into a Boolean type.


No comments:

Post a Comment