我想在MVC4中的WebGrid上实现,更新,删除操作。我该怎么做?
这是我的Web网格代码
@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;
}
如何在此网格上实现插入,更新和删除操作?
我建议您阅读文章:http://www.dotnet-tricks.com/tutorial/mvc/e2s9150113-enhancing-webgrid-webgrid-with-insert-with-insert-with-intert-with-insert--and-and-and-and-and-and-and-and-deptate-and-delete-------------------- and-delete------------and-delete-------Operations.html
几个月前,这对我有类似的问题有帮助