I know that to get the model after post, we need to write the index in the razor view. My model has an entity from entity framework called Class, but that entity has en ICollection<Student> property navigation.
I mean, I need to exposure my items from Class entity, but the problem is that this one is ICollection and I don’t have idea how to exposure the index.
Here is my razor view:
@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>
}
What can I do to get all my model after post?
1 Answer