title: MVC Submit Form With Partial View
body: <p>Apologies if this has been answered before, I can't find anything that matches my issue.</p>
  
  <p>I have a View, which contains a Partial View, and when submitting the View, the data from the partial view is not sent to the controller.  I understand that if I use an editor template, this should work, but I'm unable to use this, as I need data from my main model inside the Partial.</p>
  
  <p>My Create View (simplified):</p>
  
  <pre><code>@model CreateXmlSchemaModel
  @using (Html.BeginForm("Create", "XmlSchema", FormMethod.Post, new { enctype = "multipart/form-data" }))
  {
      &lt;fieldset&gt;
          &lt;div class="editor-label"&gt;
              @Html.LabelFor(m =&gt; m.XmlSchema.Name)
          &lt;/div&gt;
          &lt;div class="editor-field"&gt;
              @Html.EditorFor(m =&gt; m.XmlSchema.Name)
          &lt;/div&gt;
          &lt;div id="fieldmapping"&gt;
              @Html.Partial("_XmlFieldMapping")
          &lt;/div&gt;
          &lt;div&gt;
              &lt;input type="submit" value="Create" class="button" /&gt;
          &lt;/div&gt;
      &lt;/fieldset&gt;
  }
  </code></pre>
  
  <p>My Model structure (simplified):</p>
  
  <pre><code>public abstract class XmlSchemaModelContainerBase
  {
      public IEnumerable&lt;string&gt; BusinessObjects { get; set; }
      public IEnumerable&lt;XmlInputFieldModel&gt; XmlFields { get; set; }
      public IEnumerable&lt;string&gt; BusinessObjectFields { get; set; }
  }
  
  public class XmlSchemaModelContainer : XmlSchemaModelContainerBase
  {
      public XmlSchemaModel XmlSchema { get; set; }
  }
  
  public class XmlSchemaModel
  {
      public Guid Id { get; set; }
      public string Name { get; set; }
      public string BusinessObject { get; set; }
      public IEnumerable&lt;XmlSchemaField&gt; MappedFields { get; set; }
  }
  
  public class XmlSchemaField
  {
      public string XmlElement { get; set; }
      public string BusinessObjectField { get; set; }
  }
  
  public class XmlInputFieldModel
  {
      public string XmlElement { get; set; }
      public string XmlValue { get; set; }
  }
  
  public class CreateXmlSchemaModel : XmlSchemaModelContainer
  {
      [Required(ErrorMessage = "File upload required")]
      public HttpPostedFileBase Xml { get; set; }
  }
  </code></pre>
  
  <p>My Controller (I won't post it all, as I can tell immediately that my viewModel does not contains the MappedFields):</p>
  
  <pre><code>[HttpPost]
  public ActionResult Create(CreateXmlSchemaModel viewModel)
  {
  }
  </code></pre>
  
  <p>My _XmlMappedFields Partial View:</p>
  
  <pre><code>@model CherwellXmlConnector.Models.XmlSchemaModelContainer
  @{
      Model.XmlSchema.MappedFields = Model.XmlSchema.MappedFields.OrderBy(i =&gt; i.XmlElement);
  }
  
  &lt;div&gt;
      &lt;div&gt;
          @for(int i = 0; i &lt; @Model.XmlFields.Count(); i ++)
          {
              List&lt;CherwellXmlConnector.Models.XmlSchemaField&gt; fields = Model.XmlSchema.MappedFields.ToList();
              string itemValue = Model.XmlFields.FirstOrDefault(x =&gt; x.XmlElement == fields[i].XmlElement).XmlValue;
  
              &lt;div style="width: 300px; display: inline-block;"&gt;
                  @Html.DisplayFor(x =&gt; fields[i].XmlElement)
              &lt;/div&gt;
              &lt;div style="width: 300px; display: inline-block;"&gt;
                  @itemValue
              &lt;/div&gt;
              &lt;div class="busoblist" style="display: inline-block;"&gt;
                  @Html.DropDownListFor(x =&gt; fields[i].BusinessObjectField, new SelectList(Model.BusinessObjectFields))
              &lt;/div&gt;
              &lt;hr /&gt;
          }
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My intention is to display to the user in the partial, a list of all the given XmlFields and their values, and allow them to select a BusinessObjectField from a dropdown for each XmlField.  I then want this submitted back to the Controller inside the <code>IEnumerable&lt;XmlSchemaField&gt; MappedFields</code> object.  Is this possible?</p>