SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My apologies for asking, what seems like, a really basic question - but I can't appear to assign a value to a 'Choice' field programmatically and can't find anything documented anywhere.

Defined in my xml as:

 <Field Type="Choice" DisplayName="MyChoiceField" StaticName="MyChoiceField" Name="MyChoiceField"
       ID="[GUID]" Format="Dropdown" FillInChoice="FALSE" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE"  >

And my attempted assign as:

item["MyChoiceField"] = "Choice1";

But I'm getting the exception that this is an invalid value for a choice field.

share|improve this question
Thanks for your flag, but can you edit your post to avoid any possible confusion? Many thanks. - mod – SPDoctor Oct 2 '12 at 18:33
up vote 3 down vote accepted

You can use the GetFieldValue method of the field class if you are unsure of the actual type of the underling value.

For example:

item["MyChoiceField"] = listIstance.Fields["MyChoiceField"].GetFieldValue("Choice1");
share|improve this answer
This worked (hence marked as answer) about 3 hours ago, now it does not!? "A look-up field contains invalid data. Please check the value and try again." By the way - in this instance - GetFieldValue is returning a string - would it not be effectively the same to just assign the string "Choice1" directly? – JᴀʏMᴇᴇ Oct 2 '12 at 15:09
Umm - need more info - can you add the caml from the field declaration to the question? – SPArchaeologist Oct 2 '12 at 15:21
Not sure where I'd get CAML for the field declaration or what it's used for sorry. Is it used to define the field? – JᴀʏMᴇᴇ Oct 2 '12 at 15:44
My problems were completely misplaced here. It was another column that was causing the issue. Thanks a lot for all of your input anyway. – JᴀʏMᴇᴇ Oct 2 '12 at 17:01

maybe somthing like this?

// Get a reference to the field.
SPFieldMultiChoice choiceField = (SPFieldMultiChoice)list.Fields.GetField(fieldInternalName);

// Create a field value with all choices selected.
// (A CheckBoxChoiceField control would have all boxes checked.)
SPFieldMultiChoiceValue values = new SPFieldMultiChoiceValue();
foreach (string choice in choices)

// Add an item to the list.
SPListItem item = list.Items.Add();
item[SPBuiltInFieldId.Title] = "Test item";
item[choiceField.Id] = values;

share|improve this answer

Your Answer


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.