1
我有一個包含複選框的記錄網格。該複選框表示交易是否已被確認。出於測試目的,我在複選框旁邊添加了一個顯示文本,文本表明布爾值爲true。但是,複選框未被選中。當值爲真時,MVC複選框未被選中
@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>
}
謝謝!
試着清理ModelState。 – vortex 2015-04-01 17:03:40
感謝旋渦!如果你想把它放在答案部分,我可以將它標記爲答案。 – JTRookie86 2015-04-01 17:10:42
爲什麼你會在複選框後爲同一個屬性提供一個隱藏的輸入? (它會被忽略) – 2015-04-01 21:07:02