Dynamic control click event not firing properly
<p>I'm creating a next/previous function for my repeater using pageddatasource.  I added the link button control dynamically in my oninit using the following code.</p>

<pre><code>LinkButton lnkNext = new LinkButton();
lnkNext.Text = "Next";
lnkNext.Click += new EventHandler(NextPage);

if (currentPage != objPagedDataSource.PageCount)
{
    pnlMain.Controls.Add(lnkNext);
}
</code></pre>

<p>So in my initial page_load, the next link comes up fine.  There are 5 pages in my objPagedDataSource.  currentPage variable is 1.  </p>

<p>The "NextPage" event handler looks like this</p>

<pre><code>public void NextPage(object sender, EventArgs e)
{
    if (HttpContext.Current.Request.Cookies["PageNum"] == null)
    {
        HttpCookie cookie = new HttpCookie("PageNum");
        cookie.Value = "1";
    }
    else
    {
        HttpCookie cookie = HttpContext.Current.Request.Cookies["PageNum"];
        cookie.Value = (Convert.ToInt32(cookie.Value) + 1).ToString();
    }

    this.BindRepeater();
}
</code></pre>

<p>So I am incrementing the cookie I am using to track the page number and then rebinding the repeater.  </p>

<p>Here is the main issue.  The first time I click Next, it works, it goes to Page 2 without any problems.  When on Page 2, I click Next, it goes back to Page 1.  Seems like the Next event is not wiring up properly.  Not sure why, any ideas?</p>
