I have a grid that I am populating with transaction records. Each record has a check box that indicates whether the transaction has been acknowledged or not. The challenge I have is that the value that I am retrieving from the database that stores the acknowledged data is not a boolean. It returns a "Y" or a "N". Therefore, even when the record has been acknowledged, the check box does not get checked. What I want to do is to tell the page that when the AcknowledgedChar (value from db) is a "Y", set Acknowledged = true. I tried doing it from the View Model but then it confuses the application during POST. I'm sorry if this is a "stupid" question.
Here is my approach so far:
@for (int i = 0; i < Model.TransactionList.Count; i++)
{
if (Model.TransactionList[i].AcknowledgedChar == "Y")
{
Model.TransactionList[i].Acknowledged = true;
}
if (Model.TransactionList[i].AcknowledgedChar == "N")
{
Model.TransactionList[i].Acknowledged = false;
}
<tr>
<td class="hidden"> @Html.HiddenFor(m => m.TransactionList[i].ProviderTransactionId)</td>
<td class="text-center">
@Html.CheckBoxFor(m => m.TransactionList[i].Acknowledged)
@Html.HiddenFor(m=>m.TransactionList[i].AcknowledgedChar)
</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>
}
Aucun commentaire:
Enregistrer un commentaire