title: How to pass different list of data from view to controller MVC
body: <p>currently I facing a very tricky problem of passing different list of data from view to controller.
  I have created two input box to submit my data to controller so that it can be saved into CreateAccountsDB and further display it in the list of 
  Selected Subcon when Create button is pressed.</p>
  
  <p>The problem I face here is:</p>
  
  <p>when pressing the Create button with entered data from NewCompanyName textbox and NewEmail textbox, those entered data do pass data from View to Controller and save data into CreateAccountDB (not showing in View), but the entered data is not displaying in the list of Selected Subcon.</p>
  
  <p><a href="https://i.stack.imgur.com/DQ4nd.png" rel="nofollow noreferrer">Create View</a></p>
  
  <p>Here is the model.</p>
  
  <pre><code>public class Tender
      {
          public int ID { get; set; }
          public string CompanyName { get; set; }
          public List&lt;CreateAccount&gt; FrequentCompanyName { get; set; }
          public List&lt;CreateAccount&gt; SuggestCompanyName { get; set; }
          public List&lt;CreateAccount&gt; SelectedCompanyName { get; set; }
          public string CompanyNameNew { get; set; }
          public string EmailNew { get; set; }
          public int? TradeID { get; set; }
          public virtual Trade Trade { get; set; }
          public int? CreateAccountID { get; set; }
          public virtual CreateAccount CreateAccount { get; set; }
      }
  </code></pre>
  
  <p>Here is the Get Method of Create function in controller:</p>
  
  <pre><code>    [httpGet]
      public ActionResult Create(int? id)
      {
          Tender tender = new Tender();
          tender.FrequentCompanyName = db.createaccountDB.Include(tm =&gt; tm.Trade).Where(td =&gt; td.Frequency == 32).ToList();
          tender.SuggestCompanyName = db.createaccountDB.Include(tm =&gt; tm.Trade).ToList();
          if (tender.SelectedCompanyName == null)
          {
              tender.SelectedCompanyName = new List&lt;CreateAccount&gt;().ToList();
          }
          return View(tender);
      }
  </code></pre>
  
  <p>and Here is my Post Method of Create function:</p>
  
  <pre><code>    [HttpPost]
      [ValidateAntiForgeryToken]
      public ActionResult Create([Bind(Include = "ID,CompanyName,TradeID,FrequentCompanyName,SelectedCompanyName,CreateAccountID")] Tender tender ,string CompanyNameNew, string Emailnew)
      {
          CreateAccount accnew = new CreateAccount();
          accnew.CompanyName = CompanyNameNew;
          accnew.Email = Emailnew;
          if(ModelState.IsValid)
          {
              db.createaccountDB.Add(accnew);
              db.SaveChanges();
          }
  
          if (tender.SelectedCompanyName == null)
          {
              tender.SelectedCompanyName = new List&lt;CreateAccount&gt;().ToList();
          }
          tender.FrequentCompanyName = db.createaccountDB.Include(tm =&gt; tm.Trade).Where(td =&gt; td.Frequency == 32).ToList();
          tender.SuggestCompanyName = db.createaccountDB.Include(tm =&gt; tm.Trade).ToList();
          tender.SelectedCompanyName.ToList().Add(accnew);
          return View(tender);
      }
  </code></pre>
  
  <p>and Here is my Create View:</p>
  
  <pre><code>@model Tandelion0.Models.Tender
  @{
      ViewBag.Title = "Create";
  } 
  
  @using (Html.BeginForm())
  {
      @Html.AntiForgeryToken()
      &lt;div class="form-group"&gt;
          @*@Html.LabelFor(model =&gt; model.ProjectName, htmlAttributes: new { @class = "control-label col-md-3" })*@
          &lt;div class="col-md-3"&gt;
              &lt;h5&gt;New Company Name&lt;/h5&gt;
              @Html.EditorFor(model =&gt; model.CompanyNameNew, new { htmlAttributes = new { @class = "form-control" } })
              @Html.ValidationMessageFor(model =&gt; model.CompanyNameNew, "", new { @class = "text-danger" })
          &lt;/div&gt;
          &lt;div class="col-md-3"&gt;
              &lt;h5&gt;New Email&lt;/h5&gt;
              @Html.EditorFor(model =&gt;  model.EmailNew, new { htmlAttributes = new { @class = "form-control" } })
              @Html.ValidationMessageFor(model =&gt; model.EmailNew, "", new { @class = "text-danger" })
          &lt;/div&gt;
          &lt;div class="container" align="center"&gt;
              &lt;input type="submit" value="Create"  class="btn btn-default" /&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;div class="container row"&gt;
          &lt;!--selected subcon column--&gt;
          &lt;div class="container row col-sm-4"&gt;
              &lt;h4&gt;
                  Selected Subcon
              &lt;/h4&gt;
  
              &lt;div style="overflow-y: scroll; height:250px;"&gt;
                  &lt;table class="table table-hover"&gt;
                      @foreach (var item in Model.SelectedCompanyName)
                      {
                          &lt;tbody&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;
                                      @Html.DisplayFor(modelItem =&gt; item.CompanyName)
                                  &lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/tbody&gt;
                      }
                  &lt;/table&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  }
  </code></pre>
  
  <p>So far I manage to save data from view into CreateAccountsDB when create button is pressed, but those data just couldn't pass it from Post method Create function to Get method Create function in Controller. The data and the list become null immediate after come out from post method Create function.</p>
  
  <p>Because of data becomes null, the view couldn't receive any data from controller.</p>
  
  <p>May I know how can i solve the the problem of passing data from controller to view? Is the way I pass data totally wrong?
  Any advice is truly appreciated.</p>