I have an extension method for DropDownList that’s throwing Extension method can only be declared in non-generic, non-nested static classes on the keyword this. I’m not quite sure why though since I’ve seen plenty of examples with extension methods on DropDownList
public static class DropDownListExtensions {
public static void populateDropDownList(this DropDownList source, Action delegateAction) {
source.DataValueField = "Key";
source.DataTextField = "Value";
source.DataSource = delegateAction;
source.DataBind();
}
}
Possibly your
DropDownListExtensionsclass declared as nested of some other class. Move it to namespace level.