Hej.
Mam taki problem, że chcę podmieniać sobie bootstrapowe icony w widoku w zależności od wartości pola View Modelu.
W widoku mam foreacha który iteruje mi po użytkownikach i jedną kolumnę tabeli która powinna zawierać ikony świadczące o tym czy konto użytkownika zostało zablokowane czy nie.
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>@Html.Label("Status konta")</th>
<th>@Html.Label("Nazwa użytkownika")</th>
<th>@Html.Label("Dostępne operacje")</th>
</tr>
</thead>
<tbody>
@foreach (var user in Model)
{
<tr>
<td>
@if (user.UserAccountType.Contains("true"))
{
<center><i class="glyphicon glyphicon-ban-circle"></i></center>
}
else
{
<center><i class="glyphicon glyphicon-ok-circle"></i></center>
}
</td>
<td>@user.UserName</td>
<td>
@Html.ActionLink("Zablokuj", "BanUserAccount", "Admin", new { userName = user.UserName }, new AjaxOptions { HttpMethod = "POST" }) |
@Html.ActionLink("Odblokuj", "UnbanUserAccount", "Admin", new { userName = user.UserName }, new AjaxOptions { HttpMethod = "POST" }) |
@Html.ActionLink("Usuń konto", "RemoveUserAccount", "Admin", new { userName = user.UserName }, new AjaxOptions { HttpMethod = "POST" })
</td>
</tr>
}
</tbody>
</table>
Nie wiem dlaczego ale mimo iż niektórzy użytkownicy mają konto zabloowane czyli to pole user.UserAccountType zawiera true to cały czas wyświetla mi się ikona jak dla kont normalnych aktywnych :P