Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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?

Author
Account Strength
90%
Account Age
12 years
Verified Email
Yes
Verified Flair
No
Total Karma
4,721
Link Karma
2,348
Comment Karma
2,373
Profile updated: 5 days ago
Posts updated: 4 months ago

Subreddit

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