下面的代码将动作链接插入其中一个Web网格列.
@{
View.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
var usersGrid = new WebGrid(source: Model,
rowsPerPage: 40);
}
@usersGrid.GetHtml(
tableStyle: "grid",
headerStyle: "head",
alternatingRowStyle: "alt",
columns: usersGrid.Columns(
usersGrid.Column(format: (item) =>
Html.ActionLink("Edit", "Edit", new { id = item.Id})),
usersGrid.Column("Surname")
)
)
Run Code Online (Sandbox Code Playgroud)
但如果我为此交换该行:
usersGrid.Column(format: (item) => Html.CheckBox(item.Id)),
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
错误4'System.Web.Helpers.WebGrid.Column(string,string,System.Func,string,bool)'的最佳重载方法匹配具有一些无效参数.
我不太明白两者之间的区别..为什么一个工作而另一个错误?
最终目标是能够勾选多个复选框,然后发送打印信息.