Pascal Bayer
Pascal Bayer

Reputation: 2613

asp.net error CS0123: No overload matches delegate 'System.EventHandler'

CS0123: No overload for 'addItems' matches delegate 'System.EventHandler'

protected void addItems(System.EventHandler e)
        {
            DropDownList numDropDown = (DropDownList) Page.FindControl("DropDownNum");

            foreach (numOption option in numConfigManager.numConfig.numOptions.Options)
            {
                numDropDown.Items.Add(option.Value);
            }
        }

Upvotes: 0

Views: 21250

Answers (2)

V4Vendetta
V4Vendetta

Reputation: 38220

I think you messed up with the parameters of addItems if you visit EventHandlers you would know why

The standard signature of an event handler delegate defines a method that does not return a value, whose first parameter is of type Object and refers to the instance that raises the event, and whose second parameter is derived from type EventArgs and holds the event data. If the event does not generate event data, the second parameter is simply an instance of EventArgs. Otherwise, the second parameter is a custom type derived from EventArgs and supplies any fields or properties needed to hold the event data.

Upvotes: 3

Jon Skeet
Jon Skeet

Reputation: 1502056

You haven't shown anything called printListItems so it's not clear where that comes in, but I suspect you just want to change the signature of your method to:

protected void addItems(object sender, EventArgs e)

... although you should also rename it to AddItems to follow .NET naming conventions.

Upvotes: 7

Related Questions