title: Paging for ASP.net Repeater control with functionality to show next 10 pages
body: <p>I am using a paging function for repeater control and i have modified a script taken from following link</p>
  
  <p><a href="http://www.dotnetfunda.com/articles/article456-custom-seo-friendly-paging-with-aspnet-repeater-or-datalist-control-.aspx" rel="nofollow">http://www.dotnetfunda.com/articles/article456-custom-seo-friendly-paging-with-aspnet-repeater-or-datalist-control-.aspx</a></p>
  
  <p>i have modified it to some extent and it is working fine
  and paging is now displayed as </p>
  
  <p>1 | 2 | 3 | <strong>4</strong> | 5 | 6 | 7 | 8 | 9 | 10</p>
  
  <p>Paging function working fine but i need to modify script so that it will display first 5 Pages and next 5 page once user hits the next 10 Link along with Last and First Previous  Functionality </p>
  
  <p>Example based on above scenario</p>
  
  <p><strong>First</strong> - <strong>Previous</strong> 1 | 2 | 3 | 4 | 5 <strong><em>Next5</em></strong> - <strong>Last</strong> </p>
  
  <p>if i hit the Next5 link then it should display</p>
  
  <p><strong>First</strong> - <strong>5Previous</strong> 6 | 7 | 8 | 9 | 10 <strong>Next</strong> - <strong>Last</strong> </p>
  
  <p>Below is the code function and my stored procedure a</p>
  
  <pre><code>private string GetPagingDone(int thisPageNo, int totalCount, int pageSize, string pageName, int LangID, string extraQstringToAdd)
  {
      int pageno = 0;
      int start = 0;
      int loop = totalCount / pageSize;
      int ilimit = 5;
      int remainder = totalCount % pageSize;
      StringBuilder strB = new StringBuilder("", 500);
      for (int i = 0; i &lt; loop; i++)
      {
          pageno = i + 1;
          if (pageno.Equals(thisPageNo))
              strB.Append(pageno + "&amp;nbsp; ");
          else
              strB.Append("&lt;a href=\"" + pageName + "?start=" + start + "&amp;page=" + pageno  +"&amp;PageID=" + Request["PageId"] + "&amp;Language=" + Request["Language"] + "\"&gt;" + pageno + "&lt;/a&gt;  ");
          if (i + 1 == loop)
          { strB.Append("  "); }
          else 
          { strB.Append(" | "); }
          start += pageSize;
      }
      if (remainder &gt; 0)
      {
          pageno++;
          if (pageno.Equals(thisPageNo))
              strB.Append("" + pageno + "&amp;nbsp; ");
          else
              strB.Append("&lt;a href=\"" + pageName + "?start=" + start + "&amp;page=" + pageno + "&amp;PageID=" + Request["PageId"] + "&amp;Language=" + Request["Language"] + "\"&gt;" + pageno + "&lt;/a&gt;  ");
      }
  
      return strB.ToString() + "";
  }
  
  ALTER PROCEDURE [dbo].[usp_ArticleListPaging]
          @startRowIndex int,
          @pageSize int,
          @LangID int,
          @totalCount int output
      AS
      BEGIN
          SET NOCOUNT ON;
          SET @totalCount = 0
          SET @startRowIndex = @startRowIndex + 1
          BEGIN
             SELECT * FROM ( Select art_Articles.*, ROW_NUMBER() OVER (ORDER BY art_Articles.ArticlePublishDate DESC) as RowNum
             FROM art_Articles WHERE art_Articles.ArticleActive = 1 AND art_Articles.ArticleVisible = 1 AND LanguageID =@LangID) as ArticleList
             WHERE RowNum BETWEEN @startRowIndex AND (@startRowIndex + @pageSize) - 1 ORDER BY ArticlePublishDate DESC
             SELECT @totalCount = Count(ArticleID) FROM art_Articles WHERE art_Articles.ArticleActive  = 1 AND art_Articles.ArticleVisible = 1 AND LanguageID =@LangID
          END
      END
  </code></pre>
  
  <p>I have to modify the same code to use this functionality. I tried if for several hours but could not get it right so . any help in this is highly appreciated </p>
  
  <p><strong>I am not sure why i am being given -ve for asking this kind of question</strong></p>