I have a large data table that contains a checkbox for each row. I need to either pass all items that are selected as either a comma delimited list, or better yet a strongly typed IList to the controller. What is the best way to accomplish this? I know I can pass a string with no issue, but how do I get which checkboxes are selected?
Here’s what the static code looks like:
@using (@Html.BeginForm("RemoveItems", "ResultList", new { IDList = "1,2,3,4" }, FormMethod.Post))
{
<input type="submit" value="Remove Items" name="RemoveItems" />
}
You can do it like this using jQuery.
Here “input” is your array, “model” – name of action parameter.
Make sure you’ve specified contentType as application/json.