i have a foreach to iterate through items in razor syntax,
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.ColorCode)
</td>
<td>
<div style="background-color:*************"> </div>
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
</td>
</tr>
}
ColorCode is an int value ,i define an external function named IntToColorHex to convert ColorCode to equivalent hex value,i want to replace ************** with an hex color value for each row according to ColorCode,i need some thing like bellow:
<div style="background-color:IntToColorHex(@item.ColorCode)"> </div>
background-color:#@item.ColorCode.ToString("X6")