title: How to change row background color dynamic in MVC view?
body: <p>I have a dynamic table like:</p>
  
  <pre><code>&lt;tbody&gt;
    &lt;% foreach (var item in Model)
     {
    %&gt;
        &lt;tr&gt;
         ......
        &lt;/tr&gt;
    &lt;% } %&gt;
  &lt;/tbody&gt;
  </code></pre>
  
  <p>Then I want to change the row background color to different for neighbor row:</p>
  
  <pre><code>&lt;tbody&gt;
       &lt;% int i = 0;
          foreach (var item in Model)
          {
       %&gt;
       &lt;%if (i++ % 2 == 0)
       { %&gt;
         &lt;tr style="background-color:Aqua"&gt;
       &lt;%} else { %&gt;
         &lt;tr style="background-color:Fuchsia"&gt;
       &lt;%} %&gt;
       ....
        &lt;/tr&gt;
    &lt;% } %&gt;
  &lt;/tbody&gt;
  </code></pre>
  
  <p>But it doesn't work.  Or anotther way like: <code>&lt;tr style="background-color:&lt;%...%&gt;"&gt;</code>, also not work. How to resolve this problem?</p>