title: Pagination - Webmatrix/razor
body: <p>i have used Mike Brind's guide to set up pagination, which works a treat. I have also used bootstrap to create a better looking page navigation at the bottom of my page. Can you please let me know what i need to do so that the NEXT and PREV buttons work? i imagine it's be something like i+1 and i-1, but i've yet to figure it out. here's my code:</p>
  
  <p>EDITED CODE:</p>
  
  <pre><code>//Paging
  
  var pageSize = 6; 
  var totalPages = 0; 
  var count = 0;
  var page = UrlData[0].IsInt() ? UrlData[0].AsInt() : 1;
  var offset = (page -1) * pageSize;
  
  var db = Database.Open("StayInFlorida");
  var sql = "Select Count(*) From PropertyInfo ";
  count = (int)db.QueryValue(sql);
  totalPages = count/pageSize;        
  if(count % pageSize &gt; 0){
      totalPages += 1;
  }
  sql = "SELECT PropertyName, PropertyID, ResortName, NumBedrooms, NumBathrooms, NumSleeps, BriefDescription, PrimaryImage FROM PropertyInfo "+
             "Order By PropertyID OFFSET @0 ROWS FETCH NEXT @1 ROWS  ONLY;";
  
  var result = db.Query(sql, offset, pageSize);
  
  &lt;!--Pagination Start--&gt;
  &lt;div class="pagination pagination-centered"&gt;
  &lt;ul&gt;  
  @{   
      if(page &gt; 1){     
      &lt;li&gt;&lt;a href="/portfolio1/@(page-1)"&gt;Prev&lt;/a&gt;&lt;/li&gt;
      }
      for (var i = 1; i &lt; totalPages + 1; i++){
      &lt;li&gt;&lt;a href="/portfolio1/@i"&gt;@i&lt;/a&gt;&lt;/li&gt;
      }
      if(page &gt; 1){
      &lt;li&gt;&lt;a href="/portfolio1/@(page + 1)"&gt;Next&lt;/a&gt;&lt;/li&gt;
      }
  }
  &lt;/ul&gt;
  &lt;/div&gt;
  &lt;br&gt;
  &lt;!--Pagination Finish--&gt;
  </code></pre>