Hi am looking for simple if statement logic to show result if the value is same.
I have data comming from my model and have listed this is the view, which shows in a table.
On my 3rd column i want to show a green tick or red cross based on the other 2 column, they are both numbers, if the values are the same then it will show green, else it will show red.
This is my data that i get from model, PK and PartNum.
@Html.DisplayFor(modelItem => item.Pk)
@Html.DisplayFor(modelItem => item.PartNum)
This is how i started the if statement, but unsure how am going to do it:
@if (item.Pk ....//Confused how it will work here)
{
<i class="fa fa-check-circle green"></i>
}
else
{
<i class="fa fa-check-circle red"></i>
}
Any ideas or will it be easier to do this in the model.
Full view:
@if (Model.ToList().Count <= 0)
{
<h3 class="col-md-offset-4"> There is no Results</h3>
}
else
{
<table class="table table-bordered">
<tr>
<th>
@Html.DisplayNameFor(model => model.Pk)
</th>
<th>
@Html.DisplayNameFor(model => model.PartNum)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Pk)
</td>
<td>
@Html.DisplayFor(modelItem => item.PartNum)
</td>
<td>
<i class="fa fa-check-circle green"></i>
<i class="fa fa-check-circle red"></i>
</td>
</tr>
}
Aucun commentaire:
Enregistrer un commentaire