0

I made a custom gridView class which inherits from GridView.

public class CustomGridView : GridView {}

It adds a textbox in the footerRow, and I'd like to manage the changed event for this textbox directly in my page, and not in the class.

Something like :

public override void txtSearch_TextChanged(object sender, EventArgs e) { }

How could I do this ?

4

1 に答える 1

2

You would have to add a new event to your CustomGridView and raise that in the handler of the TextChanged event of the textbox.

So, in your CustomGridView:

public event EventHandler FooterTextChanged;

private void RaiseFooterTextChanged()
{
    var handler = FooterTextChanged;
    if(handler == null)
        return;

    handler(this, EventArgs.Empty);
}

public override void txtSearch_TextChanged(object sender, EventArgs e)
{
    RaiseFooterTextChanged();
}

In the class that uses CustomGridView:

customGridView.FooterTextChanged += OnGridFooterTextChanged;
于 2013-02-18T11:11:46.663 に答える