///
/// Set the values of a Lookup-Field with multiple values allowed.
///
public static void SetFieldValueLookup(this SPListItem item, string fieldName, IEnumerable
{
if (item != null)
{
SPFieldLookup field = item.Fields.GetField(fieldName) as SPFieldLookup;
SPFieldLookupValueCollection fieldValues = new SPFieldLookupValueCollection();
foreach (string lookupValue in lookupValues)
{
fieldValues.Add(GetLookupValue(item.Web, field, lookupValue));
}
item[fieldName] = fieldValues;
}
}
Example:
//Set the value of a SPFieldLookup field with multiple values allowed
string[] values = {"Hamburg", "London" };
item.SetFieldValueLookup("MultiLookupFieldName", values);
About Me
Labels
- General (1)
- SharePoint 2007 (10)
- SharePoint 2010 (3)
Buddies Blogs
Blog Archive
-
▼
2010
(9)
-
▼
February
(9)
- Opening PDF in separate window of Web Application...
- SharePoint Groups vs. Active Directory Groups
- If Current Navigation is not same as Parent Site N...
- How to Retrieve Text from Enhanced Rich Text Colum...
- Reading & Writing SPFieldUrl field values Programm...
- Setting Multiple Values of SPFieldLookup Column Pr...
- Setting Single Value of SPFieldLookup Column Progr...
- Reading Multiple Values of SPFieldLookup Column Pr...
- Reading Single Value of SPFieldLookup Column Progr...
-
▼
February
(9)
Posted by
Sreedhar Chavali
Wednesday, 17 February 2010
Labels:
SharePoint 2007
Subscribe to:
Post Comments (Atom)