Is there anyway to keep track of a Razor loop, and half way through it take some action, and then continue with the loop:
Eg. I have this:
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.Assignee)
}
I would like (pseudo):
@var halfway = Model.count / 2
@var count = 0
@foreach (var item in Model) until count == halfway
{
@Html.DisplayFor(modelItem => item.Assignee)
}
// hear we've reached halfway through, so I want to change add some HTML to the screen
<hr />
@foreach remainder (var item in Model)
{
@Html.DisplayFor(modelItem => item.Assignee)
}
Thanks for any advice,
Mak
@for(int i=0;i<= halfway ; i++)
{
@Html.DisplayFor(modelItem => item.Assignee)
}