cannot remove event handler on control

D

Daves

I have a control defined:
<asp:AccessDataSource ID="ADS1" OnUpdated="ADS_OnUpdated" [...]>


and in code behind:

protected void OnUpdated(object sender, SqlDataSourceStatusEventArgs e)
{
ADS1.Updated -= new System.EventHandler(AD1_OnUpdated);
}

And this won't work: CS0123: No overload for 'AD1_OnUpdated' matches
delegate 'System.EventHandler'

Also, is there some way to just simply clear all event handlers for the
control?
 
B

Bruce Wood

protected void OnUpdated(object sender, SqlDataSourceStatusEventArgs
e)
{
ADS1.Updated -= new System.EventHandler(AD1_OnUpda­ted);
}

And this won't work: CS0123: No overload for 'AD1_OnUpdated' matches
delegate 'System.EventHandler'

It won't work for exactly the reason that the message outlines: you
"new"ed the wrong thing. The event handler is not a
System.EventHandler. I'm guessing by the name of the argument to
OnUpdated that it's probably called a SqlDataSourceStatusEventHandler.
Try making one of those instead.
Also, is there some way to just simply clear all event handlers for
the control?

Yes. I believe that the syntax is

ADS1.Updated = null;

but I'm not sure.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top