I have code like this in my razor index view:
@for (decimal hour=7m; hour<=20.5m; hour +=0.5m)
{
var item = @Model.Items.FirstOrDefault( i=> i.Hour == hour);
if (item != null)
{
<td colspan="@item.TimeBlocks">
@item.Description
</td>
hour += (item.TimeBlocks-1)* 0.5m;
}
else
{
<td>
<a href="/Items/Add/@Model.UserId">+</a>
</td>
}
}
For some reason, the VS2013 consistently tells me "} expected" in the Error List window. The syntax highlighter shows everything highlighted fine until the curly brace right before the else.
I have tried using @: for the html tags. It works fine in the if block, but in the else block I get the following error: ":" is not valid at the start of a code block.
I have tried wrapping the html tags in a tag as well, but that doesn't work either.
How would I do this to get it to render?
foreachloop is correct?