TaxonomyField.TextField Property
SharePoint 2010
Gets or sets the GUID that identifies the hidden text field in an item.
Assembly: Microsoft.SharePoint.Taxonomy (in Microsoft.SharePoint.Taxonomy.dll)
Every TaxonomyField object contains a related hidden text field that contains a string representation of the taxonomy field value. The hidden text field is identifiedby the GUID returned by this property.
Link TaxonomyField to Term Store programmatically
TaxonomySession session = new TaxonomySession(Your_SPSite);
TermStore store = session.DefaultKeywordsTermStore;
Group grp = store.Groups.SingleOrDefault(o => o.Name == "Name_Of_Your_Term_Group");
List<TermSet> terms = new List<TermSet>();
foreach (TermSet termSet in grp.TermSets)
{
terms.Add(termSet);
}
//Update Clowns List
SPList listLeaders = web.Lists["Clowns"];
TaxonomyField taxonomyFieldRegion = (TaxonomyField)list.Fields[Name_Of_Your_Taxonomy_Field];
TermSet termRegion = terms.SingleOrDefault(o => o.Name == taxonomyFieldRegion.Title);
taxonomyFieldRegion.TermSetId = termRegion.Id;
taxonomyFieldRegion.SspId = termRegion.TermStore.Id;
taxonomyFieldRegion.Update();
TermStore store = session.DefaultKeywordsTermStore;
Group grp = store.Groups.SingleOrDefault(o => o.Name == "Name_Of_Your_Term_Group");
List<TermSet> terms = new List<TermSet>();
foreach (TermSet termSet in grp.TermSets)
{
terms.Add(termSet);
}
//Update Clowns List
SPList listLeaders = web.Lists["Clowns"];
TaxonomyField taxonomyFieldRegion = (TaxonomyField)list.Fields[Name_Of_Your_Taxonomy_Field];
TermSet termRegion = terms.SingleOrDefault(o => o.Name == taxonomyFieldRegion.Title);
taxonomyFieldRegion.TermSetId = termRegion.Id;
taxonomyFieldRegion.SspId = termRegion.TermStore.Id;
taxonomyFieldRegion.Update();
- 5/6/2010
- petkarus