title: Make partial view add item to List
body: <p>I have an ASP MVC 3 page that will allow users to create a drop down list and dynamically add items to it. For example, this is how the page looks when it first loads. </p>
  
  <p><img src="https://i.stack.imgur.com/IAfPd.png" alt="enter image description here"></p>
  
  <p>The information on the left is used to specify what page the drop down list will be located (<code>Navbar Item</code>) and what name we are going to give the drop down list (obviously <code>Drop Down List Name</code>).</p>
  
  <p>The information on the right (<code>Allowed Value</code> and <code>Display Value</code>) will be the specific drop down list items. When the user clicks on the <code>Add Another</code> link, an Ajax call goes to the controller, returns a partial view, which is then appended to the <code>Drop Down Items</code> <code>&lt;fieldset&gt;</code> like so:</p>
  
  <p><img src="https://i.stack.imgur.com/0vHTZ.png" alt="enter image description here"></p>
  
  <p>The problem is, once the user hit's the <code>Submit</code> button, none of the items make it to the controller. </p>
  
  <p>I'm still relatively new to ASP MVC, so I'm wondering if I'm even going about this the right way. Is this the proper way to dynamically add items to a list? </p>
  
  <p>Here is how this view is originally created in the controller</p>
  
  <pre><code>    public ActionResult NewList()
      {
          List&lt;DropDownValues&gt; drop = new List&lt;DropDownValues&gt;();
          drop.Add(new DropDownValues());
  
          return View(drop);
      }
  </code></pre>
  
  <p>A list of type <code>DropDownValues</code> is created and sent to the view, which has this tag at the top</p>
  
  <pre><code>@model IEnumerable&lt;Monet.Models.DropDownValues&gt;
  </code></pre>
  
  <p>The Ajax call below</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function () {
          $("#addItem").click(function () {
              if ($('#Field').text() != "" &amp;&amp; $('#DisplayPage').text() != "") {
                  $.ajax({
                      url: '@Url.Action("BlankDropDownItem", "DropDownValues")',
                      data: { field: $('#Field').val(), displayPage: $('#DisplayPage').val() },
                      dataType: 'html',
                      cache: false,
                      success: function (html) {
                          $("#items").append(html);
                      }
                  });
              } else {
                  alert("Please enter a Drop Down List Name and Navbar Item first!");
              }
              return false;
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>calls this controller method</p>
  
  <pre><code>    public ActionResult BlankDropDownItem(string field, string displayPage)
      {
          DropDownValues partial = new DropDownValues();
          partial.Field = field;
          partial.DisplayPage = displayPage;
  
          return PartialView("DropDownItemPartial", partial);
      }
  </code></pre>
  
  <p>which then appends this Partial View to the main page</p>
  
  <pre><code>@model Monet.Models.DropDownValues
  
  
  @Html.HiddenFor(model =&gt; model.Field)
  @Html.HiddenFor(model =&gt; model.DisplayPage)
  
  &lt;div class="editor-label"&gt;
      @Html.LabelFor(model =&gt; model.AllowedValue)
  &lt;/div&gt;
  &lt;div class="label-field"&gt;
      @Html.EditorFor(model =&gt; model.AllowedValue)
      @Html.ValidationMessageFor(model =&gt; model.AllowedValue)
  &lt;/div&gt;
  &lt;div class="editor-label"&gt;
      @Html.LabelFor(model =&gt; model.DisplayValue)
  &lt;/div&gt;
  &lt;div class="label-field"&gt;
      @Html.EditorFor(model =&gt; model.DisplayValue)
      @Html.ValidationMessageFor(model =&gt; model.DisplayValue)
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm trying to use the hidden fields in order to make sure all the new items are stored in the database with the correct <code>Field</code> and <code>Navbar Item</code> values (again, not sure if this is the proper way to go about this). </p>
  
  <p>Any advice/suggestions would be greatly appreciated. Thx!</p>