Asp.net mvc Asp.net Mvc表单和KendoView网格保存在一起

Asp.net mvc Asp.net Mvc表单和KendoView网格保存在一起,asp.net-mvc,grid,kendo-ui,Asp.net Mvc,Grid,Kendo Ui,我在sql server中有两个不同的表,表1是asp.net mvc表单的一部分,第二个表是kendo网格的一部分,如何通过单个按钮一次性保存这两个表 ****Table 1 is part of asp.net mvc form as following**** @using (Html.BeginForm()) { @Html.TextBoxFor(m => m.CustomerID) } ****Table 2 is part of Kendo Grid****

我在sql server中有两个不同的表,表1是asp.net mvc表单的一部分,第二个表是kendo网格的一部分,如何通过单个按钮一次性保存这两个表

 ****Table 1 is part of asp.net mvc form as following****

 @using (Html.BeginForm())
 {
 @Html.TextBoxFor(m => m.CustomerID)
 }

 ****Table 2 is part of Kendo Grid****
 @(Html.Kendo().Grid<Accounting.DAL.InvoiceDetail>()
 .Name("Grid")
 .Columns(columns =>
 {

  }
  )

我想你是MVC新手。在MVC中,每个视图都表示一个modelDomain逻辑类

@using model Applciaton.Models.SomeViewmodel
//这将创建一个表单标记。您可以在此处提及您的目标控制器操作

@using (Html.BeginForm()) 
//带有action和post属性的表单标记

@using(Html.BeginForm('action','controller',FormMethod.Post,new {id="formID"}))
{
  //your tables and kendo grid should be inside this form tag so you can post them to server.
  <input type="submit" value="save"/> //This will submit the form to controller action
}

问题是,我有两个控制器,InvoiceController和InvoiceDetailController,当然还有两个模型类。InvoiceController生成外键,并将其保存到第二个控制器InvoiceDetailController。。。。InvoiceController专用于Html.begin.form&…InvoiceDetailController专用于KendoGrid你不能这样扔控制器。视图表示模型,控制器在模型和视图之间工作。
 [HttpPost] // Post Attribute.
 public ActionResult action(SomeViewmodel obj)//Viewmodel object from view.
 {
     //you have your kendo grid data posted from view.

     // you also have other table data and all the data you specified in model will be here.

     //Save it to db from model. call the repository from here and pass relevent data.

 }