title: How to control page numbers in pagination?
body: <p>I have written below lines of code </p>
  
  <pre><code>  public void UpdatePageLables(int aPageCount)
     {
      PageCount = (int)Math.Ceiling((decimal)aPageCount / PageSize);
      int recordCount = PageCount;
      if (PageSizeChanged != null)
      {
          HiddenField hd = new HiddenField();
  
          int current;
          current = PageIndex;
          int pre;
          int Next;
          double dblPageCount = (double)((decimal)recordCount / decimal.Parse(lstPageSize.SelectedValue));
          int pageCount = PageCount;
  
          List&lt;ListItem&gt; pages = new List&lt;ListItem&gt;();
          if (pageCount &gt; 0)
          {
              // pages.Add(new ListItem("First", "1", PageIndex &gt; 1));
              current = PageIndex;
              pre = --PageIndex;
              PageIndex = current;
  
              // pages.Add(new ListItem("Previous", pre.ToString(), PageIndex &gt; 1));
  
              for (int i = 1; i &lt;= aPageCount; i++)
              {
                  pages.Add(new ListItem(i.ToString(), i.ToString(), i != PageIndex));
              }
              int currentPage = PageIndex;
              Next = ++PageIndex;
              PageIndex = currentPage;
              //pages.Add(new ListItem("Next", Next.ToString(), PageIndex &lt; pageCount));
              // pages.Add(new ListItem("Last", pageCount.ToString(), PageIndex &lt; pageCount));
  
              hd.Value = (pre.ToString());
  
  
          }
          rptPager.DataSource = pages;
          rptPager.DataBind();
  
      }
  
  }
  </code></pre>
  
  <p>And in ascx file</p>
  
  <pre><code>  &lt;div class="pagination"&gt;
       &lt;asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" OnClick="imgPre_Click"
       data-rel="tooltip" data-original-title="previous page."&gt;&amp;laquo;&lt;/asp:LinkButton&gt;
         &lt;asp:Repeater ID="rptPager"   OnItemDataBound="rptPager_ItemDataBound"  runat="server"&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:LinkButton ID="lnkPage"   runat="server" Text = '&lt;%#Eval("Text") %&gt;' CommandArgument = '&lt;%# Eval("Value") %&gt;' Enabled = '&lt;%# Eval("Enabled") %&gt;' OnClick = "Page_Changed"&gt;&lt;/asp:LinkButton&gt;
      &lt;/ItemTemplate&gt;
      &lt;/asp:Repeater&gt;   
         &lt;asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="false" OnClick="imgnext_Click" 
         data-rel="tooltip" data-original-title="next page."&gt; &amp;raquo;
       &lt;/asp:LinkButton&gt; 
                 &lt;div class="page-size"&gt;&lt;span&gt;Page Size: &amp;nbsp; &lt;/span&gt;
          &lt;asp:DropDownList runat="server" ID="lstPageSize" AutoPostBack="true" style="float:right"
          OnSelectedIndexChanged="lstPageSize_SelectedIndexChanged"&gt;
  
              &lt;asp:ListItem Text="5" Value="5"&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="10" Value="10"&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="15" Value="15" Selected="True"&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="25" Value="25"  &gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="50" Value="50"&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="75" Value="75"&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="100" Value="100"&gt;&lt;/asp:ListItem&gt;
              &lt;asp:ListItem Text="150" Value="150"&gt;&lt;/asp:ListItem&gt;
          &lt;/asp:DropDownList&gt;   
              &lt;/div&gt;
      &lt;/div&gt;     
  </code></pre>
  
  <p>Now I want to display only first seven page number links when there will be hundred page number links and rest of page number links should not be displayed.
  When user will click on ... button then page numbers from 8 to 14 should get displayed and 1 to 7 should be hidden and so on.
  Please help me !!!  </p>