/// 
/// Sets the value of a Lookup-Field.
/// 
public static void SetFieldValueLookup(this SPListItem item, string fieldName, string lookupValue)
{
    if (item != null)
    {
        SPFieldLookup field = item.Fields.GetField(fieldName) as SPFieldLookup;
        item[fieldName] = GetLookupValue(item.Web, field, lookupValue);
    }
    else
    {
        item[fieldName] = null;
    }
}
Example:
// Set the value of a SPFieldLookup field
item.SetFieldValueLookup("LookupFieldName", "LookupValue");
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)