Get and Set a SharePoint Multiple Lookup Field Value Using Server Object Model C#

At this hint, I explains How to Get and Set a SharePoint Multiple Lookup Field value using Server Object Model C#

To set a SharePoint Multiple Lookup Field value

Field Class: SPFieldLookup
Field Value Class: SPFieldLookupValueCollection

SPFieldLookupValueCollection itemValues = SPFieldLookupValueCollection();
itemValues.Add(new SPFieldLookupValue(1, "Title"));
item["FieldName"] = itemValues;
item.Update();

To get a SharePoint Multiple Lookup Field value

SPFieldLookupValueCollection itemValues = item["FieldName"] 
as SPFieldLookupValueCollection;
foreach (SPFieldLookupValue itemValue in itemValues)
{
int id = itemValue.LookupId;
string value = itemValue.LookupValue;
}

Enjoy 🙂

See also

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s