1

I have a grid of records that contain a check box. The check box indicates whether the transaction has been acknowledged or not. For testing purposes, I added a display text next to the check box and the text indicates that the boolean is true. However, the check box is not checked.

@for (int i = 0; i < Model.TransactionList.Count; i++)
        {
            <tr>
                <td class="hidden"> @Html.HiddenFor(m => m.TransactionList[i].ProviderTransactionId)</td>
                <td class="text-center">
                    @Html.DisplayTextFor(m => m.TransactionList[i].Acknowledged)
                    @Html.CheckBoxFor(m => m.TransactionList[i].Acknowledged)
                    @Html.HiddenFor(m=>m.TransactionList[i].Acknowledged)
                </td>
                <td>
                    @Html.DisplayFor(m => m.TransactionList[i].FromUicTxt)
                    @Html.HiddenFor(m => m.TransactionList[i].FromUicTxt)
                </td>
                <td>
                    @Html.DisplayFor(m => m.TransactionList[i].ToUicTxt)
                    @Html.HiddenFor(m => m.TransactionList[i].ToUicTxt)
                </td>
                <td>
                    @Html.DisplayFor(m => m.TransactionList[i].PrimaryUicTxt)
                    @Html.HiddenFor(m => m.TransactionList[i].PrimaryUicTxt)
                </td>
                <td>
                    @Html.DisplayFor(m => m.TransactionList[i].Action)
                    @Html.HiddenFor(m => m.TransactionList[i].Action)
                </td>
                <td>
                    @Html.DisplayFor(m => m.TransactionList[i].InitiatedDateString)
                    @Html.HiddenFor(m => m.TransactionList[i].InitiatedDateString)
                </td>
                <td>
                    @Html.DisplayFor(m => m.TransactionList[i].ProviderFirst) @Html.DisplayFor(m => m.TransactionList[i].ProviderLast)
                    @Html.HiddenFor(m => m.TransactionList[i].ProviderFirst) @Html.HiddenFor(m => m.TransactionList[i].ProviderLast)
                </td>
                <td>
                    @Html.DisplayFor(m => m.TransactionList[i].SSN)
                    @Html.HiddenFor(m => m.TransactionList[i].SSN)
                </td>
                <td>
                    @Html.DisplayFor(m => m.TransactionList[i].SendersFirst) @Html.DisplayFor(m => m.TransactionList[i].SendersLast)
                    @Html.HiddenFor(m => m.TransactionList[i].SendersFirst)@Html.HiddenFor(m => m.TransactionList[i].SendersLast)
                </td>
                <td>
                    @Html.DisplayFor(m => m.TransactionList[i].SendersPhone)
                    @Html.HiddenFor(m => m.TransactionList[i].SendersPhone)
                </td>
            </tr>

        }

Thanks!

4
  • Try with clearing the ModelState. Commented Apr 1, 2015 at 17:03
  • Thanks vortex! If you want to put it in the answer section i can mark it as the answer. Commented Apr 1, 2015 at 17:10
  • Why would you have a hidden input for the same property after the checkbox? (it will just be ignored) Commented Apr 1, 2015 at 21:07
  • That was there from earlier before I changed it to a checkbox Commented Apr 3, 2015 at 15:45

1 Answer 1

1

Try with clearing the ModelState. ModelState.Clear(). This way the CheckBox helper will get the value from your model and not from the ModelState, where might have a conflict with your property name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.