我想在用户点击网格中的记录时显示详细信息视图。我的代码如下:
查看:
@model IEnumerable<EmpApplication.tblEmployee>
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>List of Employees</h2>
@Html.ActionLink("Create new", "Create", "Emp", new { @class = "Create" })
@{
var grid = new WebGrid(
Model, rowsPerPage: 10,
defaultSort: "EmpID",
columnNames: new[] { "EmpID", "EName", "Address", "EmailID" }
);
}
@grid.GetHtml(
tableStyle:"Webgrid-table",
headerStyle:"Webgrid-header",
footerStyle:"Webgrid-footer",
alternatingRowStyle:"Webgrid-alternating-row",
rowStyle:"Webgrid-row-style",
fillEmptyRows:false,
mode:WebGridPagerModes.All,
columns:grid.Columns
(
grid.Column("EmpID", header:"Employee ID", style:"EmpID"),
grid.Column("EName", header:"Employee Name", style: "EName"),
grid.Column("Address", header:"Address",style:"Address"),
grid.Column("EmailID", header:"EmailID", style:"EmailID")
)
)
我必须添加哪些代码才能完成此任务?
答案 0 :(得分:0)
您需要添加另一个包含ActionLink的列,例如:
grid.Column("Details", "Details", (modelItem) => Html.ActionLink("View", "Details", new { id = modelItem.EmpID}))
这可能有用,但我没有测试过。
进一步阅读: