views:

200

answers:

0

I'm creating a paging class and trying to allow for some dynamic configuration for the method to call when Next/Previous links are clicked.

The class looks like this:

public class Pager
{
    public int StartIndex { get; set; }
    public int Range { get; set; }
    public int NumRows { get; set; }
    public event EventHandler Paging;

    public Panel CreatePaging()
    {
        Panel MyPanel = new Panel();
        LinkButton NextLB = new LinkButton();

        if (Paging != null)
        {
            NextLB.Click += Paging;
            NextLB.Text = "NotNullNext";
        }
        else
            NextLB.Text = "IsNullNext";
        MyPanel.Controls.Add(NextLB);
        return MyPanel;
    }
}

I then set the values for the properties from my aspx.cs page as follows:

search.pager.StartIndex = 0;
search.pager.Range = 10;
search.pager.Paging += new EventHandler(pager_Paging);

when I add the panel to my page, I see that it's finding the eventhandler is not null by virtue of the link button text, but inside my method, I just have a response.write() and it's never being called. LIke this:

protected void pager_Paging(object sender, EventArgs e)
    {
        Response.Write("blah");
    }

any ideas what I'm doing wrong here?