title: Dynamically load data with @Ajax.ActionLink using Skip() and Take()
body: <p>I am new to <code>ASP.NET MVC</code>, so please help me to solve this, at a first glance, simple issue.</p>
  
  <p>I have a table of students on my <code>View</code> and a <code>Load More</code> link below it. By clicking on this link I need to load more students records with AJAX.</p>
  
  <p>So this is my <code>View</code> (omitted unnecessary data)</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;table id="studentTable"&gt;
      &lt;thead&gt;
          ...
      &lt;/thead&gt;
      &lt;tbody&gt;
          @Html.Partial("_StudentDetailsList", Model)
      &lt;/tbody&gt;
  &lt;/table&gt;
  @Ajax.ActionLink("Load More", "LoadMoreStudents", new AjaxOptions
  {
      HttpMethod = "POST",
      InsertionMode = InsertionMode.InsertAfter,
      UpdateTargetId = "studentTable"
  })
  </code></pre>
  
  <p><code>_StudentDetailsList</code> partial view to display students</p>
  
  <pre class="lang-html prettyprint-override"><code>@model IEnumerable&lt;MvcApplication1.Models.Student&gt;
  @foreach (var item in Model)
  {
      &lt;tr&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.LastName)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.FirstName)
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  </code></pre>
  
  <p>action</p>
  
  <pre class="lang-cs prettyprint-override"><code>public ActionResult LoadMoreStudents(int skip = 0)
  {
      return PartialView("_StudentDetailsList", studentRepository.Get(orderBy: s =&gt; s.OrderBy(st =&gt; st.FirstName).OrderBy(st =&gt; st.LastName)).Skip(skip).Take(10));
  }
  </code></pre>
  
  <p>So as you can see, I want to load next 10 students every time, but I have to know how much are already loaded. So the question is: from where should I get this <code>skip</code> parameter which I want to pass to the <code>Action</code> from the <code>View</code>. How can I count on the <code>View</code> how many partial views are already loaded and how many students each partial has? Or is it a bad practice to pass this parameter to action, maybe I should handle it somewhere else (e.g. some service)? Please advice the right way to do this. Thanks.</p>
  
  <p>P.S. Please feel free to edit the caption as I can't come up with appropriate one.</p>