Aidan Garnish

Collaboration Not Competition

Web part custom property - dropdown list

It isn't immediately obvious how to include a drop down list as a custom property on a web part. To do this you simply use an enum.


//create enum

public enum ProductByEnum

{Type = 0,



//create get/set for the property

protected ProductByEnum productsBy;

[Personalizable(PersonalizationScope.User),WebBrowsable, WebDisplayName("Products By"),WebDescription("Use this property to change web part grouping")]public ProductByEnum ProductsBy


get { return productsBy; }

set { productsBy = value; }


A dropdown list will now appear in the miscellaneous section of your web part custom properties containing the enum values.


Add comment