This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
7
mvc checkboxfor cannot convert string to bool
Post Body
I have the following code:
<table id="form-parameters" class="parameters">
@if (Model.Parameters != null && Model != null)
{
for (int i = 0; i < Model.Parameters.Count; i )
{
<tr>
<td>@Html.CheckBoxFor(x => Model.Parameters[i].Display)</td>
<td><input name="form-parameter-mark-delete" type="checkbox" /></td>
<td>@Html.TextBoxFor(x => Model.Parameters[i].Key)</td>
<td>@Html.TextBoxFor(x => Model.Parameters[i].Value)</td>
</tr>
}
}
</table>
I also have jquery code to add a new parameter that appends a new table row with the same formatting that POST requires. However when I post it comes back and states that it cannot convert a string into a bool and was wondering how to fix this issue. Did I need a hidden field for the jquery one that when the checkbox is changed update the hidden text box with a 0 or 1 or a true or false with the proper name or something?
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 8 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/csharp/comm...