I've got a MVC site/view that shows a series of checkboxes across the top that correspond to the years available in the in my webgrid records. I would like to click on the checkboxes to filter the data in the webgrid. I have that working but when I click on the headings in the webgrid to sort it my checkboxes reset back to unchecked.
I am used to webform programming so have always relied on viewstate to maintain the selections.
How do I do this in the MVC world?
Here is my code to display the checkboxes in the view:
@using (Ajax.BeginForm(new AjaxOptions { InsertionMode=InsertionMode.Replace,UpdateTargetId="myGrid"}))
{
foreach (var y in Model.Years)
{
<input type="checkbox" name="cbYears" value="@y.Value" />
<label for="cbYears">@y.Value</label>
}
<br />
<input type="submit" value="Filter Results" />
}
The grid is displayed in a partial view.
TIA