I have the following snippet of code inside one of my views:
foreach (var topEmployer in Model.TopEmployers)
{
//Some link - works fine for all iterations
@Html.ActionLink(....)
//This partial view is only rendered for the LAST iteration of this loop.
@Html.Partial("partialViewName", topEmployer)
<br />
}
Stepping through the loop with a debugger where I have a breakpoint in the partial view confirms the issue: The debugger only steps into the partial view at the last iteration not on any previous. Seems like it just ignores the partial view on previous iterations.
I'm not sure how I would resolve this issue. Have tried to search for similar problems but without luck. What am I doing wrong?
EDIT: Ok, I placed the breakpoint in the partial view inside an if statement that wasn't being entered. So, that's an entirely different issue. The partial view is being rendered but as there is no content it's just empty and the breakpoint obviously never got hit.