Monday, April 4, 2011

Updating Taxonomy field with default value


Writing to columns based on the Managed Metadata field type is a little
different from writing to columns of other types. First, get a reference to the column in the
list, and then call the SetFieldValue() method to update the value of a specific list item, as
shown in the listing below:

List selectedTerms = new List();
selectedTerms.AddRange(terms.ToList());
TaxonomyField locationTags = listItem.Fields["Location Tag"] as TaxonomyField;
locationTags.SetFieldValue(listItem, selectedTerms);
listItem.Update();


------------
Levis Hotel
http://levishotel.com