title: MVC Persist Model when paging
body: <p>I have a dropdown list with check boxes. The selected value is bound to my view model. The data is paged using PagedList.Mvc. All works fine when I select some checkboxes and then hit the search button, but when I click onto another page the check box list becomes null so the list loses what is checked. How can I get the model to persist whilst paging.</p>
  
  <p>So my html looks like this</p>
  
  <pre><code>    &lt;ul class="dropdown-menu"&gt;
          @for (int i = 0; i &lt; Model.Units.Count; i++)
          {
              @Html.CheckBoxFor(m =&gt; m.Units[i].Selected) 
              @Html.HiddenFor(m =&gt; m.Units[i].UnitId) 
              @Html.LabelFor(m =&gt; m.Units[i].Selected,
                         Model.Units[i].UnitName)
              &lt;br /&gt;
              }
      &lt;/ul&gt;
  
   &lt;button class="btn btn-primary" type="submit" id="btnSave" name="Command" value="Save"&gt;Search&lt;/button&gt;
  </code></pre>
  
  <p>and further down the paging</p>
  
  <pre><code> @Html.PagedListPager(Model.SearchData, page =&gt; Url.Action("Index", new HistoricDataViewModel { Page = page }))
  </code></pre>
  
  <p>and my model looks like this</p>
  
  <pre><code>public class HistoricDataViewModel
  {
      public HistoricDataViewModel()
      {
          Page = 1;
      }
  
      public StaticPagedList&lt;Data_Search_Result&gt; SearchData { get; set; }
      public List&lt;Units_Getall_Result&gt; Units { get; set; }
      public int Page
      {
          get; set;
      }
  }
  </code></pre>
  
  <p>When I hit my search button it is submitting the form. Is the problem because the paging plugin isn't doing a submit?</p>