views:

42

answers:

2

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 (CancelledCard 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?

+2  A: 

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.

Darin Dimitrov
A: 
<%: Html.CheckBoxFor(item >= item.Checked) %>

is wrong. It should be:

<%: Html.CheckBoxFor(item => item.Checked) %>
awrigley