title: Display One record at a time in MVC through List
body: <p>I have 5 records coming from a simple select stored procedure.</p>
  
  <pre><code>ID Name
  1  RecordOne
  2  RecordTwo
  3  RecordThree
  4  RecordFour
  5. RecordFive
  </code></pre>
  
  <p>Requirement is to display one record at a time example:</p>
  
  <p>Record One</p>
  
  <p>Previous    Next</p>
  
  <p>Two Action links or buttons with Previous and Next text.
  If user clicks Next user will see </p>
  
  <pre><code>RecordTwo
  </code></pre>
  
  <p>and so on,same for previous case.</p>
  
  <p>My model</p>
  
  <pre><code>namespace MVCLearning.Models
  
  {
  
  public class VMNews
  {
      public List&lt;Student&gt; StudentDetails { get; set; }
  }
  
  public class Student
  {
      public int ID { get; set; }
      public string Name { get; set; }
  
  }
   }
  </code></pre>
  
  <p>Action </p>
  
  <pre><code> public ActionResult Index()
      {
          VMNews objnews = new VMNews();
          objnews.StudentDetails = db.Database.SqlQuery&lt;Student&gt;("usp_studentdetails").ToList();
          return View(objnews);
      }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>&lt;div&gt;
  @foreach (var item in Model.SD.Take(1))
  {
      &lt;h3&gt;@item.Name&lt;/h3&gt;
      &lt;h3&gt;@item.Age&lt;/h3&gt;
  
  }
  @Html.ActionLink("Next", "index", new { Model.SD[0].ID})
  @Html.ActionLink("Previous", "index", new { Model.SD[0].ID })            
  </code></pre>
  
  <p></p>
  
  <p>The way I have written the view is totally wrong am not getting how and what to write on the action and what to write on the View.</p>
  
  <p>What will be one of the way to achieve this.</p>