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

I want to add values to a lookupmulti field with c#. the form shows the field correctly but my code just won't work:

SPList list = SPContext.Current.Web.Lists["testlist"];
SPListItem item = list.GetItemById(someId);
SPFieldLookupValueCollection fieldValues = new SPFieldLookupValueCollection();
foreach(int id in itemIds) {
   fieldValues.Add(new SPFieldLookupValue {LookupId = id});
item["lookupmultifield"] = fieldValues;

The code above is not exactly my code, but it's how i thought it should work. FieldValues has 2 entries, but only the first is inserted in the lookupmulti field. can anyone help?

share|improve this question

here's a code fragment that's similar but 'list.Items.Add() & item.Update()' are missing from your code

SPList list = SPContext.Current.Web.Lists["testlist"];  
SPListItem item = list.Items.Add();  
SPFieldLookupValueCollection fieldValues = new

fieldValues.Add (new SPFieldLookupValue(1, "SomeValue1"));  // add other field values or in loop

item["lookupmultiField"] = fieldValues;
share|improve this answer
thanks Shegit - I am still grappling with the editing.. – Supriyo SB Chatterjee Feb 16 '12 at 17:23
thanks, but i updated some other fields and updated after that. – domueni Feb 20 '12 at 8:00
Any Example with Linq? – tola Jul 6 '15 at 10:16

I'm not sure, but there are 2 constructors for SPFieldLookupValue class:

SPFieldLookupValue(String) // Initializes a new instance of the SPFieldLookupValue class that is based on the specified field value.
SPFieldLookupValue(Int32, String) // Initializes a new instance of the SPFieldLookupValue class that is based on the specified lookup identifier (ID) and value.

It looks like you should specify Id and Value of related objects...

share|improve this answer
thanks but I tried that already but same result – domueni Feb 16 '12 at 14:20
will post the solution when i can – domueni Feb 16 '12 at 14:24
Are you sure that you use correct Value? '<Field ID="x" Type="Lookup" List="x" ShowField="Title"...' you should use value of field that is set in ShowField property of list schema. In example above it is Item["Title"] – Alexander Feb 16 '12 at 14:37
up vote 0 down vote accepted

i wrote Mult="True" instead of Mult="TRUE"

I should not listen to VS 2010 intellisense

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.