When there is only one person to select I still need to assign the hardcoded value 'TRUE' to the People[i].IsSelected property to satisfy my validation.
How can I do that?
@if (hasMoreThanOnePerson)
{
<td>
@Html.CheckBoxFor(m => m.People[i].IsSelected)
</td>
}
else
{
@Html.HiddenFor(m => m.People[i].IsSelected, true) // Set TRUE always to hidden field within for loop with indexer
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…