I have a following view model and it will be used by a search control that I\'m working on.
public class SearchViewModel
{
public SearchViewModel()
{
Because you have a static list, you can quickly hack your way to creating markup which will be bound correctly:
@model MyDLL.WebUI.Models.SearchCategoriesViewModel
@{
var i = 0;
}
@foreach (var c in Model.Categories)
{
@Html.Hidden("Categories[" + i.ToString() + "].Id", c.Id);
@Html.Hidden("Categories[" + i.ToString() + "].Name", c.Name);
@Html.Label(c.Name);
@Html.CheckBox("Categories[" + i.ToString() + "].IsSelected",c.IsSelected);
}
This is a quick and ugly solution. However, I would suggest that you reconsider how you are generating the markup in your partial view.