我想在MVC4中的WebGrid上实现插入,更新,删除操作。我怎么能这样做?
这是我的网格代码
@model IEnumerable<MVC24Jan.UserTable>
@{
ViewBag.Title = "ShowRecord";
WebGrid grid = new WebGrid(Model);
}
<h2>ShowRecord</h2>
<div>
@grid.GetHtml(
tableStyle: "webgrid",
headerStyle: "head",
alternatingRowStyle: "alt",
columns:grid.Columns(
grid.Column("UserId"),
grid.Column("UserName"),
grid.Column("Address")
)
)
</div>
这是我的控制器代码
public ActionResult ShowRecord()
{
DBLayer db = new DBLayer();
var usertablList= db.GetAllRecord();
return View(usertablList);
}
public List<UserTable> GetAllRecord()
{
List<UserTable> userTable = new List<UserTable>();
userTable = entity.UserTables.ToList();
return userTable;
}
如何在此网格上实施插入,更新和删除操作?
答案 0 :(得分:1)