Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.