Reputation: 39
I need to show the data on the basis on below condition. Need to show 5 columns and then next data in next row. I am new for MVC. Please help.
@{
int count = 0;
@foreach (var item in Model)
{
if (count == 0) { @:<tr> }
<td>
<p align="center">item.WeekNumber</p>
</td>
<td>
item.OpenFirst<br>
item.OpenSecond<br>
item.OpenThird
</td>
<td><font size="6">OpenResult</font></td>
<td>
item.CloseFirst<br>
item.CloseSecond<br>
item.CloseThird
</td>
if (count == 5) { count = -1; @:</tr> }
count++;
}
}
Upvotes: 0
Views: 795
Reputation: 487
Hello I think the problem is @ on the first foreach loop. Please remove it and try. And one more thing if you want to use html in the Razor code then you can use @Html.Raw()
. (Example @Html.Raw("<tr>")
)
Upvotes: 1