Grid: How do I use checkboxes?

127 views
Skip to first unread message

geoffrey payne

unread,
Oct 3, 2011, 10:58:21 AM10/3/11
to mvccontrib-discuss
I am using MVC2, so if you can help me update the checkbox syntax I
would be very grateful.
Anyway my main problem is that I have defined a chekbox for each row
on my grid, but I do not seem to be able to post them to my
controller. So the user will check some of them, but when the submit
button is clicked all the values remain unchecked.
What do I need to do to get this to work?

<%= Html.Grid(Model.TeamMembers).Columns(column =>
{
column.For(model => model.Surname);
column.For(model => model.Forename);
column.For(model => model.DaysLeftThisYear).Named("Days Left This
Year");
column.For(model => model.DaysLeftNextYear).Named("Days Left Next
Year");
column.For(model => Html.CheckBox("chkbox",
model.SelectForConfirmationFlag))
.Named("Select?")
.Sortable(false);
}).Sort((GridSortOptions)ViewData["sort"]) %>

Jeremy Skinner

unread,
Oct 4, 2011, 12:02:53 PM10/4/11
to mvccontri...@googlegroups.com
It's difficult to see what's wrong without looking at your controller
code. I'd suggest looking at the raw Request.Form values to see what's
actually being posted.

Jeremy Skinner
Sent from my iPhone

> --
> Contact Jeffrey Palermo or Eric Hexter with specific questions about the MvcContrib project. Or go to http://mvccontrib.org
>
> To unsubscribe from this group, send email to mvccontrib-disc...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/mvccontrib-discuss?hl=en

Reply all
Reply to author
Forward
0 new messages