Javascript MVC 5追加Jquery输入表单绑定为对象

Javascript MVC 5追加Jquery输入表单绑定为对象,javascript,c#,jquery,asp.net-mvc,forms,Javascript,C#,Jquery,Asp.net Mvc,Forms,我在这里尝试了Append和Bind解决方案 但还是有问题 我有两个模型。第一是定价 public class Pricing { public int PricingID { get; set; } public int PricePerSack { get; set; } public virtual ExpensePersack ExpensePerSacks { get; set; } public string companyName { get;

我在这里尝试了Append和Bind解决方案

但还是有问题

我有两个模型。第一是定价

public class Pricing
{
    public int PricingID { get; set; }

    public int PricePerSack { get; set; }
    public virtual ExpensePersack ExpensePerSacks { get; set; }

    public string companyName { get; set; }
    public string BankName { get; set; }
    public string Branch { get; set; }
    public Terms Term { get; set; }
    public int ChequeNumber { get; set; }
    public DateTime? DateofCheque { get; set; }


}
   public enum Terms { Cash,Cheque};

}
接下来是ExpensePerSack模型

public class ExpensePersack
    {
        public int ExpensePersackID { get; set; }
        public int PricingID { get; set; }

        public string Description { get; set; }
        public int Amount { get; set; }

}
控制器

public ActionResult Create([Bind(Include = "PricingID,PricePerSack,companyName,BankName,Branch,Term,ChequeNumber,DateofCheque")] Pricing pricing, ExpensePersack ExpensePersack)
    {
        if (ModelState.IsValid)
        {
            db.Pricings.Add(pricing);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        return View(pricing);
    }
现在在视图中。这是剪辑有困难的时间编辑这个问题,因为代码得到破坏时,复制粘贴

现在在控制器中,我没有添加要保存的费用模型或代码,因为在Post方法中。来自控制器的费用为空

我仍然不知道如何将数据发送到控制器,甚至不知道如何通过它们的ID删除附加列

 @model RMQGrains.Models.Pricing


    ... bunch of codes from Pricing Models editor for...

    <div id="InsertView"><div>



    <input type="button" id="addrow" value="Add">

<div id="NewBatchProduct" style="display:none">
    <tr>
        <td><input type="text" name="ExpensePricing[#].Description" value />   </td>
     <td><input type="text" name="ExpensePricing[#].Amount" value /></td>
      <td>
         <input type="hidden" name="ExpensePricing.Index" value="%" />
         <a class="deleteRow">Delete</a>
        </td>
    </tr>
</div>



    @section Scripts {
    @Scripts.Render("~/bundles/jqueryval")

      <script>
       $("#addrow").click(function () {
           var index = (new Date()).getTime(); // unique indexer
           var clone = $('#NewBatchProduct').clone(); // clone the       BatchProducts item
           // Update the index of the clone
           clone.html($(clone).html().replace(/\[#\]/g, '[' + index + ']'));
           clone.html($(clone).html().replace(/"%"/g, '"' + index + '"'));
           $("#InsertView").append(clone.html());
       });
   </script>

   }
@model RMQGrains.Models.Pricing
... 定价模型编辑器中的一组代码。。。
删除
@节脚本{
@Scripts.Render(“~/bundles/jqueryval”)
$(“#添加行”)。单击(函数(){
变量索引=(新日期()).getTime();//唯一索引器
var clone=$('#NewBatchProduct')。clone();//克隆BatchProducts项
//更新克隆的索引
html($(clone.html().replace(/\[\]/g,['+index+']);
html($(clone.html().replace(/“%”/g,“'+index+”));
$(“#InsertView”).append(clone.html());
});
}

包括一些代码,否则这太宽泛了,无法给出一个像样的答案。动态添加项目和@Stephen的一些选项我已经尝试@for(int I=0;Im.BatchProducts[I].Quantity)@Html.TextBoxFor(m=>m.BatchProducts[I].BatchName)//添加以下内容以允许在视图Delete中动态删除项目}正如您所建议的,我在标记中添加了Delete。我怎么删除这个电话?@Aizen,你需要用新代码编辑你的问题-在评论中太难阅读了。谢谢,我会构建我问题中的所有内容。