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 trying to add a new list item into a sharepoint 2010 list using the client side object object in C#. I'm having an issue trying to set multiselect values.

I saw online to set the values in an array, so i did something like this in code.

Array arr = value.Split(new string[] { ", " }, StringSplitOptions.None); 
newItem["My MultiSelect Column Name"] = arr; 

//save changes 
newItem.Update();

//commit changes 
ctx.ExecuteQuery();

After I do the above I go to SharePoint and see that the row has the correct items in the array (delimited with ';'), but when I go in and edit that row, none of the items are actually checked.

Has anyone else run into this?

share|improve this question

migrated from stackoverflow.com Jun 3 '13 at 11:53

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer 1

Multiple-Column Lookup value is represented as an array of FieldLookupValue objects.

How to get multiple Lookup field value:

var countryValues = item["Country"] as FieldLookupValue[];

How to set multiple Lookup field value:

var lookupVals = new[] { new FieldLookupValue { LookupId = 1 }, new FieldLookupValue { LookupId = 2} };
item["Country"] = lookupVals;
item.Update();
context.ExecuteQuery();
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.