How do I use an enum with custom values for a Sharepoint Web part?
Posted
by Jeff
on Stack Overflow
See other posts from Stack Overflow
or by Jeff
Published on 2010-06-16T21:23:24Z
Indexed on
2010/06/17
10:53 UTC
Read the original article
Hit count: 195
I'm trying to design a Web Part that has a drop-down list for the user to choose from. Eventually, these values will be automatically generated based on some kind of outside data source, so they're going to have somewhat arbitrary numeric values associated with them. This is the code I have now:
public enum filterChoice
{
All=0,
BOCC=12,
Sustainability=15,
Clerk=4,
DA=13,
Emergency=7,
Highlights=3,
POS=6,
PR=1,
PH=5,
SHPR=2,
Test=8,
Transportation=14,
Volunteer=16
};
These are different categories I want the user to choose from. When I choose one and save the settings for my Web Part, Sharepoint is only saving the values in numeric order; that is, All=0, BOCC=1, Sustainability=3 [...] so my Web Part then thinks the user chose the value with the corresponding number (PR when they chose BOCC, Highlights when they chose Sustainability, etc.) How can I make Sharepoint honor my custom values?
© Stack Overflow or respective owner