Question

I am fairly new to SharePoint development and as you may all know that it is very basic for one to know how to access fields in a choice column...

My problem: I want to access the values of the Check Boxes from a Choice Column.

For Example: I have a document library called Libe, this document library has a custom column with type Choice and has 4 checkboxes with the values:

  1. Category 1
  2. Category 2
  3. Category 3
  4. Category 4

How do I get the values like literally the text values of what is in the Check Box List: "Category 1", "Category 2" ... "Category 4".

Any ideas?

I can access the column fine and get the selected values, I just do not know how to get the values the user can choose from.

Your help is very appreciated.

-------------------------------------

ANSWER:

 SPFieldMultiChoice Fld = (SPFieldMultiChoice)list.Fields["Column"];
                                List<string> fieldList = new List<string>();
                                foreach (string str in Fld.Choices)
                                {
                                    fieldList.Add(str);


     }

Above is the answer, I can't answer my own question until I have a 100 rep.

Was it helpful?

Solution

The choice columns are worked with SPFieldMultiChoice and SPFieldMultiChoiceValue classes. Here are a few posts with examples -

How to retrieve and update from a multi choice Checkboxlist field

Properly Populating and Retrieving SharePoint Field Data

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top