@(Html.DataList<ProductModel>(Model.FeaturedProducts, 2,
@<div class="item-box">
@Html.Partial("_ProductBox", @item)
</div>
))
Now I get the general idea. I also have an adequate understanding of how generics and delegates work to grasp the role they play in producing the resulting HTMLString.
But, but but....
I can't figure out how the second parameter to Html.Partial is instantiated the way it is. It is the object represented by "@item", which is of type ProductModel, and which is the ProductModel that is being iterated over at the time the DataList function goes through its first parameter, itself a collection of ProductModels.
For all intents and purposes, the type of @item should not be recognized by the IDE at coding time, but it does! Intellisense is happy to provide me with the type of @item!
I understand what it is and what it does, but I am asking how this is possible. In other words, I am looking for an answer that explains the inner workings of the part of MVC and/or Nop framework that makes this happen.
If you take a look at rest of the view, you'll notice that @item is not defined in it. There is no outer loop that instantiates an @item for you. And yet there it is, all properly instantiated and populated, exposing its data to the _ProductBox.cshtml.
I'm new to MVC, and I've already done a fair bit googling over this problem, but to no avail! Please help me solve this annoying puzzle!