Reputation: 135
Here is my Webgrid:
{
var grid = new WebGrid(Model, rowsPerPage: 15, ajaxUpdateContainerId: "PListGrid");
@grid.GetHtml(
tableStyle: "webgrid",
headerStyle: "webgrid-header-a",
footerStyle: "webgrid-footer",
alternatingRowStyle: "webgrid-alternating-row",
selectedRowStyle: "webgrid-selected-row",
rowStyle: "webgrid-row-style",
columns:
grid.Columns(
grid.Column("ITEMNMBR", "Part #", canSort: true,
format: (item) => Html.ActionLink(((string)item.ITEMNMBR),
"PCreate", "PartsLabor", new { ITEMNMBR = @item.ITEMNMBR }, null)),
grid.Column("ITEMDESC", "Part Description", canSort: true)
))
}
When the view loads, and you hover over a link for the ITEMNMBR/Part # column, you see something similar to:
domain.com/PartsLabor/PCreate?ITEMNMBR=ABCDEFG
I also have a viewbag item (CALLNBR). How do I get the actionlink to resolve to:
domain.com/PartsLabor/PCreate?ITEMNMBR=ABCDEFG&CALLNBR=123456
In other words, how do you pass multiple parameters to the Html.ActionLink?
Upvotes: 0
Views: 4963
Reputation: 7605
Like this:
@Html.ActionLink("Link Text", "ActionName", "ControllerName", new {param = value, param2 = value2}, null)
Just plug your model properties in the appropriate place, and note that the param name must match exactly the param name in the Action method signature. Oh, and don't miss the null at the end, you need it!
Upvotes: 3