Q:

html.raw is not rendering

I'm trying to modify the background color of a table row using the code below. However, I'm getting a parser error because the closing tr tag doesn't have a matching opening tr. I tried using @: instead of @Html.Raw(...), but I get the same error. If I type the tr tag outside of the conditional block, it renders a single tag and the table loads fine (just without alternating background colors).
<table>
    <tr>
        <th>Count</th>
        <th>Username</th>
    </tr>
 @foreach (var item in Model)
    {
        i++;
        if (i % 2 == 0){
            @Html.Raw("<tr>");
        }
        else{
            @Html.Raw("<tr style=\"background-color: #c9c9c9\">");
        }

        <td>@i.ToString()</td>
        <td>
            @Html.DisplayFor(modelItem => item.User)
        </td>
    </tr>
    }
</table>

A:

You don't need @Html.Raw on those places.
Simply leave the tags as is  <tr>
Update... adding your code.
<table>
    <tr>
        <th>Count</th>
        <th>Username</th>
    </tr>
 @foreach (var item in Model)
    {
        i++;
        if (i % 2 == 0){

            <tr>
        }
        else{
          <tr style='background-color: #c9c9c9'>
        }

        <td>@i.ToString()</td>
        <td>
            @Html.DisplayFor(modelItem => item.User)
        </td>
    </tr>
    }
</table>

A:

Do this instead.
<table>
    <tr>
        <th>Count</th>
        <th>Username</th>
    </tr>
    @foreach (var item in Model)
    {
        string backColor;
        i++;
        if (i % 2 == 0) {
            backColor = "whatever this color should be";
        }
        else {
            backColor = "#c9c9c9";
        }
    <tr style="background-color: @backColor">
        <td>@i.ToString()</td>
        <td>
            @Html.DisplayFor(modelItem => item.User)
        </td>
    </tr>
    }
</table>

