title: Get data from a foreach partial view in razorview
body: <p>I am new to MVC3 and C#.</p>
  
  <p>Here is my current model</p>
  
  <pre><code>@model Reports.ViewModels.ContentViewModel
  &lt;div&gt;Total Hours: &lt;/div&gt;
  
  foreach (var user in Model.Users.ToList()) {
     @Html.Partial("_DirectReports", user)
  }
  </code></pre>
  
  <p>This is working great, I then have HTML in these partial view that renders everything I want using another @model.
  The problem is I want to add all the data together.</p>
  
  <p>I want to create a var outside the foreach
  The foreach inserts data into the var and return it after the foreach is complete like so</p>
  
  <pre><code>@model Reports.ViewModels.ContentViewModel
  
  @{var Total = 0}
  foreach (var user in Model.Users.ToList()) {
     @Html.Partial("_DirectReports", user)
     //@Total is assigned a value in the partial view
  }
  
  &lt;div&gt;Total Hours: @Total&lt;/div&gt;
  </code></pre>
  
  <p>If this is possible that would be great thks</p>