title: Linkbutton inside Repeater for paging ASP.Net
body: <p>I'm doing a webpage with a search that brings a lot of information from MSSQL. What I did is a stored procedure that return only the page to be seen on the website.</p>
  
  <p>Right now I'm working on the paging as I need to show something similar than google. If you are at page 1 they show first 10 pages and if you are at page 19 they show since page 9 to 28.</p>
  
  <p>I think the best option to show the page numbers is using a linkbutton inside a repeater.  The problem that I have now is that I do not know the best way to take the page number at postback.</p>
  
  <p>Doing a quick sample I assigned an ArrayList to repeater.datasource:</p>
  
  <pre><code>  &lt;asp:Repeater ID="Repeater2" runat="server"&gt;
      &lt;ItemTemplate&gt;
              &lt;asp:LinkButton ID="LinkButton1" runat="server" CommandArgument="&lt;%# Container.DataItem %&gt;"&gt;&lt;%# Container.DataItem %&gt;&lt;/asp:LinkButton&gt;
      &lt;/ItemTemplate&gt;
    &lt;/asp:Repeater&gt;
    &lt;asp:LinkButton ID="LinkButton2" runat="server" CommandArgument="4654"&gt;Test #1&lt;/asp:LinkButton&gt;
  </code></pre>
  
  <p>At my Default.aspx.cs file I have the next code</p>
  
  <pre><code>    protected void Page_Load(object sender, EventArgs e)
      {
          if (this.IsPostBack)
          {
              string x = LinkButton2.CommandArgument;
              //string y = LinkButton1.CommandArgument;
  //I know this line will not work since the Linkbutton1 is inside the Repeater.
              }
  </code></pre>
  
  <p>What Shall I do to make it works?</p>
  
  <p>Does anyone has a better solution for this paging?</p>
  
  <p>Thank you</p>
  
  <p>Jerry</p>