ASP.NET MVC2复选框中的一个表 [英] ASP.NET MVC2 Checkboxes in a table
问题描述
我目前正在试图建立在asp.net MVC2其中包括每排一个复选框视图。这将是一个标志中,而且会有上,然后可以用于多个缺失视图一个按钮。
I'm currently trying to create a view in asp.net MVC2 which includes a checkbox in each row. This will be a "mark" box, and there will be a button on the view which can then be used for multiple deletion.
我有一个包含所列出的对象列表的模式,所以我有一些code其内容为: -
I have a model which contains a list of the objects being listed, so I have some code which reads as:-
<% foreach (CancelledCard item in Model.CancelledCards) { %>
我再试图用
<%: Html.CheckBoxFor(item >= item.Checked) %>
但我得到一个错误。
but I'm getting an error.
我在想什么?是什么在MVC2这样做的正确方法?
What am I missing? What's the right way to do this in MVC2?
推荐答案
在C#中的lambda前pression使用 =&GT;
,而不是&GT; =
:
In C# a lambda expression uses =>
and not >=
:
<%: Html.CheckBoxFor(item => item.Checked) %>
此外,而不是说你得到一个错误,你可能会发布错误消息。这本来是更清晰。
Also instead of saying that you get an error, you could have posted the error message. It would have been much more clear.
这篇关于ASP.NET MVC2复选框中的一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!