Действия ASP.NET MVC принимают массивы в качестве параметров.
[HttpPost]
public ActionResult EditGenres(string[] genres, int ID)
{
PublishedItem item = GetPublishedItemByID(ID);
item.Genres = genres.Select(x=> new Genre{ Name = x}); // this LINQ query just projects each string into a new genre. You can use w/e method you want to manipulate this string array into genres.
return RedirectToAction("Success");
}
Чтобы заполнить массив, просто используйте то же значение для атрибута name
в поле формы.
<% Html.BeingForm() %>
<input type="checkbox" value="Genre1" name="genres">
<input type="checkbox" value="Genre2" name="genres">
<input type="checkbox" value="Genre3" name="genres">
<input type="checkbox" value="Genre4" name="genres">
<input type="hidden" value="1" name="ID" />
<input type="Submit" value="Submit Generes">
<% Html.EndForm() %>