title: Change the table row color based on what is displayed from the Enum property on a view. ASP.Net MVC
body: <p>I'm trying to change the <code>table row</code> color based on what is displayed in the <code>table</code> on my <code>index</code> page of my <code>delivery</code>. </p>
  
  <p>I have 3 <code>statuses</code> for <code>delivery</code> which I've hard-coded using <code>enum</code> in the <code>model</code>. Now based on the respective status I want the table row to change color. </p>
  
  <p>So for example, if my <code>status</code> is equal to <code>Dispatched</code>, change the <code>table row</code> color to <code>.success</code> which my bootstrap takes as green.</p>
  
  <p>This is what I have tried so far, but it's not working. Does any one have any ideas for a fix? </p>
  
  <p><strong>Delivery Index View</strong></p>
  
  <pre><code>@foreach (var item in Model)
  {
      string style = item.Status.Equals("Dispatched") ? "success" : null;
  
      &lt;tr class="@style"&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Driver.First_Name)
              @Html.DisplayFor(modelItem =&gt; item.Driver.Last_Name)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Status)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Dispatched_Date) at
              @Html.DisplayFor(modelItem =&gt; item.Dispatched_Time)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Delivered_Date) -
              @Html.DisplayFor(modelItem =&gt; item.Delivered_Time)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Delayed_Date) -
              @Html.DisplayFor(modelItem =&gt; item.Delayed_Time)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.ActionLink("View Delivery", "Details", new { id = item.DeliveryID })
          &lt;/td&gt;
          &lt;td&gt;
              @Html.ActionLink("Delete Delivery", "Delete", new { id = item.DeliveryID })
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  </code></pre>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>public enum Status
  {
     Dispatched, Delayed, Delivered
  }
  public class Delivery
  {
  
      public int DeliveryID { get; set; }
      [Display(Name = "Driver")]
      public int DriverID { get; set; }
      public Status Status { get; set; }
  </code></pre>