Custom Repeater Control with Paging and Page Navigation Controls
<p>I'm trying to create a customer repeater with Paging and accompanying controls e.g. Next Prev buttons. </p>

<p>So far I have the custom repeater with Paged data working fine, and I can get it to render the navigation buttons aswell but I can't assign events to the Navigation LinkButtons.</p>

<p>Here's the Custom Repeater class:</p>

<pre><code>using System.Web.UI.WebControls;
using System.Web.UI;
using System.Data;
using System.Collections;
using System;

namespace ASPresentation.Controls 
{
[ToolboxData("&lt;cc:PagedRepeater runat=server&gt;&lt;/cc:PagedRepeater&gt;")]
public class PagedRepeater : Repeater
{
    public int PageSize { get; set; }
    public int CurrentPageIndex { get; set; }
    public PagedDataSource pagedData = new PagedDataSource();
    LinkButton NextBtn = new LinkButton();
    LinkButton PrevBtn = new LinkButton();

    public bool IsLastPage
    {
        get
        {
            return pagedData.IsLastPage;
        }
    }
    public bool IsFirstPage
    {
        get
        {
            return pagedData.IsFirstPage;
        }
    }

    public override object DataSource
    {
        get
        {
            return base.DataSource;
        }
        set
        {
            pagedData.DataSource = (IEnumerable)value;
        }
    }

    protected void NextButtonClick(object sender, EventArgs e)
    {
        if (!IsLastPage)
        {
            CurrentPageIndex++;
        }
    }

    protected void PrevButtonClick(object sender, EventArgs e)
    {
        if (!IsFirstPage)
        {
            CurrentPageIndex--;
        }
    }

    protected override void OnInit(EventArgs e)
    {
        NextBtn.Text = "Next";
        PrevBtn.Text = "Prev";
        NextBtn.Click += new EventHandler(NextButtonClick);
        PrevBtn.Click += new EventHandler(PrevButtonClick);
        base.OnInit(e);
    }

    protected override void Render(HtmlTextWriter writer)
    {
        base.Controls.Add(PrevBtn);
        base.Controls.Add(NextBtn);
        base.Render(writer);
    }

    public override void DataBind()
    {
        pagedData.AllowPaging = true;
        pagedData.PageSize = PageSize;
        pagedData.CurrentPageIndex = CurrentPageIndex;
        base.DataSource = pagedData;
        base.DataBind();
    }
}
}
</code></pre>

<p>Anyone got any ideas?</p>
