title: ASP.NET MVC 2: foreach, RenderPartial, ViewModel
body: <p>I'm trying to employ a technique that I came across that seems quite clean.</p>
  
  <p>Previously, my Partial had the loop inside of it. I was looping through the mode within the Partial... but then I came across an example where the <code>foreach</code> loop existed in the main page, while the partial was just the meat of the loop.</p>
  
  <p>They accomplished it like so:</p>
  
  <pre><code>&lt;% int index = 1; // iteration
  foreach (var item in Model.Deal) { %&gt;
  
       &lt;% Html.RenderPartial("DealList", item, new ViewDataDictionary {{ "index", index }}); %&gt;
  
  &lt;% i++; // increase the interation
  } %&gt;
  </code></pre>
  
  <p>But in my example, I'm using a ViewModel, and now that I'm in the partial, I can't access "item" like I used to be able to. Instead my only option is <code>Model.Deal</code> ...</p>
  
  <p>What is the point of passsing "item" with the <code>RenderParial</code> helper if I can't access it by saying <code>item.StoreName</code>? Note, both the View and the Partial are strongly typed to the same ViewDataModel.</p>