这是我的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)
))
}
当视图加载,并将鼠标悬停在ITEMNMBR / Part#列的链接上时,您会看到类似于以下内容的内容:
domain.com/PartsLabor/PCreate?ITEMNMBR=ABCDEFG
我还有一个viewbag项目(CALLNBR)。 如何让actionlink解析为:
domain.com/PartsLabor/PCreate?ITEMNMBR=ABCDEFG&CALLNBR=123456
换句话说,如何将多个参数传递给Html.ActionLink?
答案 0 :(得分:3)
像这样:
@Html.ActionLink("Link Text", "ActionName", "ControllerName", new {param = value, param2 = value2}, null)
只需将模型属性插入适当的位置,并注意param名称必须与Action方法签名中的param名称完全匹配。 哦,不要错过最后的空,你需要它!