Ok,
I have a new MVC project which uses the entity framework. I'm spitting out messages (This is a bulletin board style section) now depending on some conditional factors the row in the table output must have a differant class style.
The model that is passed to the page from the controller is the entity Model (Called Messages and contains the same fields as the database)
Now to get the row styles in I did the following,
<%
int i = 0;
foreach (var message in ViewData.Model.MessageList)
{
string className = "rowEven";
if (i % 2 == 0) { className = "rowOdd"; }
if (message.Deleted) { className = "deleted"; }
if (message.AuthorisedBy == null) { className = "notAuth"; }
if (message.Deleted) { className = "deleted"; }
%>
<tr class="<%=className%>">
<td><%= Html.CheckBox("mc1")%></td>
<td>
<%= Html.ActionLink(message.Title, "Details", new { id = message.MessageID })%>
</td>
<td>User Name Here</td>
<td><%= Html.Encode(message.PublishDateTime.ToString())%></td>
</tr>
<%
i++;
}
%>
Which is pretty ugly, there must be a better way of doing this, any suggestions?