-1

我在视图上有一个 HTML 表,用户在运行时在其中添加了一些数据。我想通过控制器将该表的所有行保存在数据库中。就像 winform 应用程序一样,每个循环用于保存所有行。

4

1 回答 1

1

为您的表创建一个视图模型:

public class YourTable
{
    public IEnumerable<YourRow> Rows { get; set; }
}

创建强类型视图。

@model SomePath.YourTable

// Your table editable content
// form with submit value that will post viewmodel to controller action

在控制器操作中您应该处理帖子:

[HttpPost]
public ActionResult SaveTable(YourTable yourTable)
{
    // save your table to the database
}
于 2013-10-08T20:37:50.807 回答