Hello all, this is a follow-up to the question I posted yesterday. I was able to get the checkboxes implemented correctly, thank to all your suggestions. Now I'm trying to tackle the second issue which is maintaining the checkbox state during a page refresh or when a user clicks the back button on there browser. Again I have the following sample code in my view:
<tr>
<td><label for="Name">Name</label></td>
<td><%= Html.Encode(entity.CONTACT_NAME)%></td>
<td><%= Html.CheckBox("Name", false, new {@value = Html.Encode(entity.CONTACT_NAME)}) %></td>
</tr>
When I check the box, I get the following value for the Name key in the ModelState "John Doe, false". From what I understand, the checkbox html helper gets its value from the ModelState. But when the page re-renders and gets to this particular line of code, I get the following error:
The parameter conversion from type 'System.String' to type 'System.Boolean' failed
Again, my goal is to simply maintain the checkbox state, not sure what is going on here.
UPDATE:
If the checkbox gets the value from the ModelState when re-rendering and if the keys are stored as strings, how do I convert them to boolean values?