how to save multiple data in database from dynamic added textbox in mvc
<p>How do I save multiple data from dynamically added textbox via javascript? I have done the dynamically added textbox for product list and payment terms. What should I do for the controller and View</p>

<p>I have test <a href="http://demo.dotnetawesome.com/mvc/insert-multiple-record-to-database-at-a-time-aspnet-mvc4" rel="nofollow noreferrer">This</a> but didn't work</p>

<p>here is my controller</p>

<pre><code> public ActionResult Create([Bind(Include = "PurchaseInvoiceTable,PurchaseInvoiceDetailsTable,PaymentTerm")]InvoiceWrapper model)            
{
    try
    {

        if (ModelState.IsValid)
        {

            db.PurchaseInvoiceTables.Add(model.PurchaseInvoiceTable);                    
            db.SaveChanges();

            var PID = model.PurchaseInvoiceTable.PurchaseInvoiceID;
            model.PurchaseInvoiceDetailsTable.InvoiceID = PID;
            model.PaymentTerm.InvoiceID = PID;

            db.PurchaseInvoiceDetailsTables.Add(model.PurchaseInvoiceDetailsTable);
            db.PaymentTerms.Add(model.PaymentTerm);
            db.SaveChanges();

            return RedirectToAction("Index");
        }

        ViewBag.InvoiceID = new SelectList(db.PurchaseInvoiceTables, "PurchaseInvoiceID", "PurID", model.PurchaseInvoiceDetailsTable.InvoiceID);
        ViewBag.InvoiceID = new SelectList(db.PurchaseInvoiceTables, "PurchaseInvoiceID", "PurID", model.PaymentTerm.InvoiceID);             
        return View(model);
    }
    catch (DbEntityValidationException e)
    {
        //catch validation here
    }

}
</code></pre>

<p>Here is my invoiceWrapper</p>

<pre><code>using System;
using System.Collections.Generic;

namespace OnlineInvoiceSystem.Models
{
    public class InvoiceWrapper
    {
        public PurchaseInvoiceTable PurchaseInvoiceTable { get; set; }
        public PurchaseInvoiceDetailsTable PurchaseInvoiceDetailsTable { get; set; }
        public PaymentTerm PaymentTerm { get; set; }
    }
}
</code></pre>

<p>here is my javascript <a href="https://jsfiddle.net/va672kky/" rel="nofollow noreferrer">You can test it on Jsfiddle</a></p>

<p>my view is this</p>

<pre><code>@model OnlineInvoiceSystem.Models.InvoiceWrapper 

@{ Layout = null; Layout = "~/Views/Shared/_Layout.cshtml"; } 

@using (Html.BeginForm()) { 

@Html.AntiForgeryToken()

&lt;form&gt;

  @Html.ValidationSummary(true, "", new { @class = "text-danger" })

  &lt;h2&gt;Product List&lt;/h2&gt;

  &lt;div class="panel panel-default product_wrapper"&gt;

    //dynamic added textbox will appear here

  &lt;/div&gt;



  &lt;button class="add_field_button btn btn-primary pull-right"&gt;Add More Fields&lt;/button&gt;

  &lt;div class="wrapper-payment-details"&gt;

    &lt;tr style="background-color:black; color:white;" class="payment_term_wrapper"&gt;

      // here is the dynamic added payment terms textbox

    &lt;/tr&gt;

  &lt;/div&gt;

  &lt;div class="form-group"&gt;
    &lt;div&gt;
      &lt;input type="submit" value="Create" class="btn btn-primary pull-right" /&gt; @Html.ActionLink("Back", "Index", null, new { @class = "btn btn-small btn-danger pull-right", @style = "margin-right:2%;" })
    &lt;/div&gt;
  &lt;/div&gt;

&lt;/form&gt;
  }
</code></pre>