Model Binding an IList of selected items only
- by jeef3
I have an action method setup:
public ActionResult Delete(IList<Product> products)
And a table of products in my view. I have got Model Binding working so that on submit I can populate the products list. But I would like to populate it with only the products that are selected via a checkbox.
I think I could do it by changing the action method to this:
public ActionResult Delete(IList<Product> products, IList<int> toDelete)
And passing the list of check boxes to the toDelete but I would really like to avoid changing the method signature if possible.
Is there a way to pass only the selected items? Or am I going to have to write a custom ModelBinder?