我生成的局部視圖模型的foreach元素名稱產生不正確
@model IEnumerable<ViewModel.vm_Master_QuestionSet_AnswerOptions>
@foreach (var item in Model)
{
<div class="form-group">
@Html.LabelFor(m => item.AnswerShownOrder, item.AnswerShownOrder.ToString(), new { @class = "control-label col-md-3 col-sm-3 col-xs-12" })
<div class="col-md-4 col-sm-4 col-xs-4">
@Html.TextBoxFor(m => item.AnswerOptionText, new { @class = "form-control", @id = item.PK_MasterQuestion_AnswerOptionID })
</div>
<div class="col-md-2 col-sm-2 col-xs-2">
@Html.CheckBoxFor(m => item.CorrectAnswer, new { @class = "form-control", @id = "chk" + item.PK_MasterQuestion_AnswerOptionID })
</div>
</div>
}
當但創建控件的名稱開始與item.please看到波紋管圖像 在I類有2個屬性
public ICollection<string> AnswerOptionText { get; set; }
public ICollection<bool> CorrectAnswer { get; set; }
如果名字是這樣生成的,則值不會映射。
爲什麼它會生成這樣的?我如何防止這種情況?