Wednesday, 28 August 2013

foreach contents getting skipped

foreach contents getting skipped

I've got an ASP.NET MVC4 view that looks like this:
@model IEnumerable<Bloom.Models.GalleryImageVM>
<div id="gallery">
@foreach (var img in Model)
{
<a href="#" id="@img.Title">
<img src="@img.URL" />
</a>
}
</div>
GalleryImageVM is an object with two string properties:
public class GalleryImageVM
{
public string URL { get; set; }
public string Title { get; set; }
}
Data is definitely getting populated since Model has the expected values
in it. However, nothing inside the foreach gets hit. A breakpoint won't
get hit, and if I step through it, the execution will touch each of the
expected parts of the foreach definition, but won't enter the curly
braces.
What am I missing?

No comments:

Post a Comment