MVC Razor, add if statement to foreach loop
问题 I'm trying to add data from my model to a table with razor. My problem is that i want an if statement to decide what class the tagg should be and i can't get this to work. When i add the if i get the following error when i run the code The foreach block is missing a closing "}" character How should i add the if statement? This is my current code @{ var counter = 0; } @foreach (var item in Model) { if(item.status == "Active") { <tr> } else { <tr class="danger"> } <td>@counter</td> <td>@item