I'm checking if my ViewBag comes up something
Then I do the following:
@if (ViewBag.Itens != null)
{
foreach (var item in ViewBag.Itens)
{
<div class="col-md-6">
<div class="checkbox">
<label>
<input type="checkbox" name="ItensCheck" value="@item.Value" checked="@item.Selected" />
@item.Text
</label>
</div>
</div>
}
}
else
{
@Html.Raw("Não existe Itens cadastrado.")
}
When it comes to the list of items, it goes through my foreach and does everything as I want, but when it does not have anything, it does not make the condition else I want.