I have a view where data is displayed in which data can be entered (Notes)
@model IList<Proyecto01.Models.Nota>
@{
ViewBag.Title = "Notas";
}
<h2 class="text-center"> Notas</h2>
@using (Html.BeginForm("ActualizarNotas", "Nota", FormMethod.Post)) {
<th>
@Html.DisplayName("Nombres")
</th>
<th>
@Html.DisplayName("Apellido Materno")
</th>
<th>
@Html.DisplayName("Apellido Paterno")
</th>
<th>
@Html.DisplayName("Nota 1")
</th>
<th>
@Html.DisplayName("Nota 2")
</th>
<th>
@Html.DisplayName("Nota 3")
</th>
<th>
@Html.DisplayName("Nota 4")
</th>
<th>
@Html.DisplayName("Nota 5")
</th>
<th>
@Html.DisplayName("Promedio")
</th>
<th></th>
</tr>
@for (var i = 0; i < Model.Count; i++)
{
<tr>
<td>
@Html.DisplayFor(x=> x[i].nombres)
</td>
<td>
@Html.DisplayFor(x=> x[i].apellidoMaterno)
</td>
<td>
@Html.DisplayFor(x => x[i].apellidoPaterno)
</td>
@Html.HiddenFor(x=> x[i].rutAlumno)
@Html.HiddenFor(x=>x[i].idAsignatura)
<td>
@Html.TextBoxFor(x=>x[i].nota1, new { @class = "form-control ",
style = "width:50px;", maxlength = 20 })
</td>
<td>
@Html.TextBoxFor(x => x[i].nota2, new { @class = "form-control
", style = "width:50px;", maxlength = 20 })
</td>
<td>
@Html.TextBoxFor(x => x[i].nota3, new { @class = "form-control
", style = "width:50px;", maxlength = 20 })
</td>
<td>
@Html.TextBoxFor(x => x[i].nota4, new { @class = "form-control
", style = "width:50px;", maxlength = 20 })
</td>
<td>
@Html.TextBoxFor(x => x[i].nota5, new { @class = "form-control
", style = "width:50px;", maxlength = 20 })
</td>
<td>
@Html.TextBoxFor(x => x[i].promedio, new { @class = "form-
control ", @readonly = "readonly", style = "width:50px;", maxlength =
20 })
</td>
</tr>
}
</table>
}
<td>
<input type="submit" value="Guardar" class="btn btn-danger" /><br />
</td>
How do I receive this data in the controller and be able to execute an Add method which stores this data in the database.
[HttpPost]
public ActionResult ActualizarNotas(ICollection<Nota> objetos)
{
Nota n = new Nota();
n.actualizarNotas();
return RedirectToAction("Notas","Nota");
}