I'm using MVC 4 and i've created a controller with read/write actions and views using EF. I've created a new view (so now i have index, details, edit, delete, create and newview) and the new view has the exact same code as the index but when i try to acess the new view it gives this error:
An exception of type 'System.NullReferenceException' occurred in App_Web_hcu5njnc.dll but was not handled in user code
The code of the view (same has index but without the create edit details links):
@model IEnumerable<GestorSalas.Models.Horario>
@{
ViewBag.Title = "ProcurarSalas";
}
<h2>Procurar Salas</h2>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Disciplina.Nome)
</th>
<th>
@Html.DisplayNameFor(model => model.Sala.Nome)
</th>
<th>
@Html.DisplayNameFor(model => model.Dia)
</th>
<th>
@Html.DisplayNameFor(model => model.HoraEntrada)
</th>
<th>
@Html.DisplayNameFor(model => model.HoraSaida)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Disciplina.Nome)
</td>
<td>
@Html.DisplayFor(modelItem => item.Sala.Nome)
</td>
<td>
@Html.DisplayFor(modelItem => item.Dia)
</td>
<td>
@Html.DisplayFor(modelItem => item.HoraEntrada)
</td>
<td>
@Html.DisplayFor(modelItem => item.HoraSaida)
</td>
</tr>
}
</table>
Can someone help me? Why it gives that error? Those parameters already have data, they are not empty