如何使一个MVC 3的WebGrid与复选框列? [英] How to make a MVC 3 Webgrid with checkbox column?
问题描述
在code下面将插入一个ActionLink的到Web网格中的一个。
The code below will insert an actionlink into one of the web grids' columns.
@{
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")
)
)
但是,如果我对攻线这样的:
But if i exchange that line for this:
usersGrid.Column(format: (item) => Html.CheckBox(item.Id)),
我得到这个错误:
I get this error:
错误4最好的重载方法
难挡
System.Web.Helpers.WebGrid.Column(字符串,
串,System.Func,
字符串,布尔)'有一些无效
参数。
Error 4 The best overloaded method match for 'System.Web.Helpers.WebGrid.Column(string, string, System.Func, string, bool)' has some invalid arguments.
我不明白..两者之间的差异为什么一部作品和其他错误?
I don't quite understand the difference between the two.. why does one work and the other error?
的最终目标是要能够勾出了一些复选框,然后发送打印自己的信息。
The ultimate goal is to be able to tick a number of check boxes and then send to print their info.
推荐答案
这是对我到底是什么工作。
This is what worked for me in the end.
usersGrid.Column(header: "Print?", format: @<text><input name="Prints"
type="checkbox" value="@item.ID" /></text>),
得到称谢尼克·哈里斯,答案在他的博客在这里找到评论:
<一href=\"http://www.nickharris.net/2010/10/a-first-look-at-the-asp-net-mvc-3-webgrid/\">http://www.nickharris.net/2010/10/a-first-look-at-the-asp-net-mvc-3-webgrid/
这篇关于如何使一个MVC 3的WebGrid与复选框列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!