我知道要在發佈後獲取模型,我們需要在剃鬚刀視圖中編寫索引。我的模型有一個來自實體框架的實體,名爲Class,但是該實體具有屬性導航ICollection<Student>
。爲什麼在發佈我的模型爲空?循環索引
我的意思是,我需要暴露我的項目從類實體,但問題是,這是ICollection,我不知道如何暴露索引。
這裏是我的Razor視圖:
@model Contoso.MvcApplication.Models.Assignment.ShareAssignmentViewModel
@{
ViewBag.Title = "ShareAssignment";
}
<h2>Share Assignment: @Model.Assignment.Name</h2>
@for (int i = 0; i < Model.Classes.Length; i++)
{
<section>
<h3>@Model.Classes[i].Name</h3>
@for (int j = 0; j < Model.Classes[i].Students.Count; j++)
{
@Html.CheckBox(modelItem => Model.Classes[i].Students // what now?? [j])
}
</section>
}
我能做些什麼讓我的帖子後,所有的模型?
是的,對不起,這是CheckBoxFor – 2013-02-09 01:24:32