Pardon my ignorance of delegates. I’m trying to register a handler for a GridView event in an asp.net WinForms page:
Class myClass
{
void grid_rowDataBound(object sender, GridViewCommandEventArgs e)
{ blah blah }
}
myClass myClassInstance = new myClass(); //done in Page_Load
<asp:GridView ID="server_grid" runat="server" OnRowDataBound="myClassInstance.grid_RowDataBound">
yadda yadda
</asp:GridView>
I am getting a runtime error “Delegate to an instance method cannot have null ‘this'”. My only solution at this point is to define a new page function that simply calls my class method and register that page function in OnRowDataBound. But isn’t there a direct way to register a class method for GridView events without the indirection? Or do all page contol events require handlers defined in the page class?
You could use the following, but then this is just a short way of defining a new function like you already suggested.