在 ASP.NET MVC3 中,我使用 Webgrid 来填充数据。我有一列,我希望该列中的数据具有操作链接。我的表看起来像这样
Roll No | StudentName | Class | Course | |
======================================================
110 | XY | 5 | Science| ViewDetails
我想为行中的每个 ViewDetails 提供一个链接,以便移动到所需的操作。我还想将 RollNo 的值传递给操作。如何做到这一点。我尝试过这样的事情。
var grid = new WebGrid(source: Model, canPage: true, rowsPerPage: 10);
grid.Pager(WebGridPagerModes.NextPrevious);
@grid.GetHtml(tableStyle: "grid",
htmlAttributes: new { id = "DataTable" },
headerStyle: "grid-header",
footerStyle: "grid-header",
alternatingRowStyle: "grid-alternating-row",
selectedRowStyle: "grid-selected-row",
rowStyle: "grid-row-style",
columns: grid.Columns(
grid.Column(columnName: "RollNo", header: "RollNo"),
grid.Column(columnName: "StudentName", header: "StudentName"),
grid.Column(columnName: "Class", header: "Class"),
grid.Column(columnName: "Course", header: "Course"),
grid.Column(header: "",
format:item =>
new HtmlString(Html.ActionLink("ViewDetails","Home"))));