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.
Eg.
//create enum
public enum ProductByEnum
{Type = 0,
Brand,
Chemistry};
//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.
Currently rated 3.7 by 3 people
- Currently 3.666667/5 Stars.
- 1
- 2
- 3
- 4
- 5