I try to do something like that. When my employee does not have a particular value that it is not displayed. I tried to do it like this:
@foreach (var item in Model)
{
if (!item.Przewodnik.Uprawnienia.IsNullOrWhiteSpace()) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Przewodnik.Pracownik.Osoba.Imie)
</td>
(...)
But it give me a .NullReferenceException
.
if(item.Przewodnik.Uprawnienia != null){...}
I tried this as well, but also give error.