ASP.NET MVC2 Checkboxes in a table
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.
I have a model which contains a list of the objects being listed, so I have some code which reads as:-
<% foreach (Cancelled开发者_运维百科Card item in Model.CancelledCards) { %>
I've then tried to use
<%: Html.CheckBoxFor(item >= item.Checked) %>
but I'm getting an error.
What am I missing? What's the right way to do this in MVC2?
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.
<%: Html.CheckBoxFor(item >= item.Checked) %>
is wrong. It should be:
<%: Html.CheckBoxFor(item => item.Checked) %>
精彩评论