1
Guys, I’m developing an application that manages Courses, and I have the following problem. On my screen Administrator I need the fields Course Name, Student Name and the countryside Approved which is a field booleano. That screen is where the Administrator tells which pupil is approved in the course you signed up for. Only in my View only fields appear Course Name and the countryside Approved and nay appears the Student Name, as shown below.

The other problem is that this field of mine Approved when I mark the checkbox he’s not saving like true in the Database, is always getting false.
Action Aprovacao of controller Course
public ActionResult Aprovacao()
{
return View(db.Cursos.ToList());
}
My View Aprovacao
@model IEnumerable<MeuProjeto.Models.Curso>
@{
Layout = "/Views/Shared/_Layout.cshtml";
}
<h2>Aprovação</h2>
<table class="table table-hover">
<tr>
<th>
Curso
</th>
<th>
Aluno
</th>
<th>
Aprovado?
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Nome_Curso)
</td>
<td>
@Html.DisplayFor(modelItem => item.AlunoCursos)
</td>
<td>
@*@Html.DisplayFor(modelItem => item.Aprovado)*@
<input type="checkbox" id="Aprovado" name="Aprovado" value="Aprovado"/>
</td>
</tr>
}
</table>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Hey @Gypsy this code here
var alunoCursos = contexto.AlunoCursos.Include(ac => ac.Aluno).ToList();goes in mycontrollerright?– Novato
@Beginner This. Just send to View
alunoCursos.– Leonel Sanches da Silva
My field Approved still not saving @Gypsy, when I update the page o
checkboxempty turn, and the bank is also not saving astrue.– Novato
@Rookie Already put a breakpoint on Action that Ajax calls?
– Leonel Sanches da Silva
No, I’ll do it now @Gypsy
– Novato
I think the problem is here
[HttpPost]
 public ActionResult Aprovar(int id)
 {
 var alunoCursos = db.AlunoCursos.Include(ac => ac.Aluno).ToList();

 return View(alunoCursos);
 }. Can you shed some light on this part here // Select here the Alunocurso and change the Approved.. I did not...– Novato
The selection of
alunoCursosdoes not go intoAprovar. See my edition. InsideAprovarwill select only onealunoCursoand there you edit the boolean.– Leonel Sanches da Silva
Let’s go continue this discussion in chat.
– Novato
Give me just one example @Gypsy of how I would make this selection of a
alunoCursowithin theAprovarand edit my fieldbooleano, because here I could not.– Novato
@Newbie Edited the answer.
– Leonel Sanches da Silva
here on this stretch
alunoCurso.Aprovado = !alunoCurso.Aprovado;error of Nullreferenceexception.– Novato
@Newbie It means that
alunoCursoisnull, and who did not find the record byidpast. You are performing debug of the code you are writing?– Leonel Sanches da Silva
Yes @Gypsy, when debugging here in this section
var alunoCurso = db.AlunoCursos.FirstOrDefault(ac => ac.AlunoCursoId == id);it features aid = 5– Novato