Get available SharePoint list field options in a field type (Multi)Choice from codebehind




In a list with a field type “Choice” you can know available options of this field from codebehind without reading all list values and not making them unique with Distinct(). Especially, you can’t just read and make Distinct() list values if your field allows multiple choice or if you don't have all options.

It’s easy with SharePoint class SPFieldChoice and method "Choices" that returns the Choices that are used in the multichoice field.

For example, our list is on current SPWeb, our list is called "Products" and it’s in the current SPWeb and our field is called "Brand"

 

So we use only SharePoint object model and we don’t need to think out anything.



MarkiMarta.com. Notes of web-specialist
Since 2009
18+
Count SharePoint List Items with PowerShell

Today I needed to know a quantity of SharePoint List. Somewhy SharePoint doen't give this information using common tools. But...

Close