I need to switch between the CSS class if the message is read.
In simple form, it should be like this:
if (item.status == "Unread") { <tr style="font-weight:bold"> ... } else { <tr> ... }
I am having problems with this. Can anything tell me well to do this? Should I use an HTML helper or something else?
This is the full code:
@foreach (var item in Model) { if (item.status == "Unread") { <tr style="font-weight:bold"> <td> @Html.DisplayFor(modelItem => item.timestamp) </td> <td> @Html.DisplayFor(modelItem => item.subject) </td> <td> @Html.DisplayFor(modelItem => item.message_text) </td> <td> @Html.DisplayFor(modelItem => item.status) </td> <td> @Html.DisplayFor(modelItem => item.user_sender.username) </td> <td> @Html.DisplayFor(modelItem => item.user_reciever.username) </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> } }
source share