1
在ASP.NET MVC3中,我使用Webgrid來填充數據。我有一列要讓該列中的數據具有操作鏈接。我的表看起來像這樣在ASP.net MVC3中如何提供WebGrid中的鏈接
Roll No | StudentName | Class | Course | |
======================================================
110 | XY | 5 | Science| ViewDetails
我想提供一個鏈接到該行中每個ViewDetails所以,我想傳遞一個值是RollNo的動作移動到所需action.As好。這是如何實現的。我嘗試過這樣的事情。
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"))));
謝謝Jan :)完整答案的格式爲:@ @ Html.ActionLink(「View Details」,「StudentDtls」,「Home」,new {id = item.RollNo},null) –
Aada