title: How to dynamically add items to my collection from a view when single partial requires multiple objects?
body: <p>I have a list of items displayed in my view. I need to be able to manually add items to this list from the UI with an add button. I know I need to load a partial view with javascript to get the new item to be displayed.</p>
  
  <pre><code>@{var count = 0;}
  @foreach (var dx in Model.Patient.DxList)
  {    
      &lt;div class="form-field"&gt;
          &lt;label&gt;@(++count)&lt;/label&gt;
          @Html.HiddenFor(d =&gt; dx.DxIndex)
          @Html.TextBoxFor(d =&gt; dx.Dx, new { @class = "small" })
          &lt;span class="description"&gt;@((dx.DxRef != null) ? dx.DxRef.Title : "")&lt;/span&gt;
          @Html.DropDownListFor(d=&gt; dx.Indicator, new SelectList(Model.Codes, "Value", "Description", dx.Indicator), "Please select", new { @class = "" })
      &lt;/div&gt;
  }
  </code></pre>
  
  <p>However, because my item contains both a TextBox and a DropDownList, which is populated with Codes, does my partial view need a ViewModel too? To contain not only the Dx, but the list of appropriate Codes to create the list?</p>
  
  <pre><code>public class DxSingleViewModel
  {
      public Dx Dx { get; set; }
      public List&lt;Code&gt; Codes { get; set; }
  }
  </code></pre>
  
  <p>No idea if this is the general approach, or if I'm off base.</p>