如何将枚举与 Sharepoint Web 部件的自定义值一起使用?
我正在尝试设计一个 Web 部件,它有一个下拉列表供用户选择。最终,这些值将根据某种外部数据源自动生成,因此它们将具有与之关联的任意数值。这是我现在拥有的代码:
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
};
这些是我希望用户从中进行选择的不同类别。当我选择一个并保存 Web 部件的设置时,Sharepoint 仅按数字顺序保存值;也就是说,All=0、BOCC=1、Sustainability=3 [...],因此我的 Web 部件会认为用户选择了具有相应数字的值(选择 BOCC 时的 PR、选择 Sustainability 时的突出显示等)如何使 Sharepoint 尊重我的自定义价值观?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您可以只在枚举中放入字符串,并使用 Dictionary<> 将其转换为 Web 部件代码中的关联数值。或者什么?
Guess you could put only strings in your enumeration and do the translation to the associated numeric values in the code of your webpart using a Dictionary<> or something?