Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

How to programmatically add value in metadata column ?

$
0
0

Hello,

I have one list with metadata column.I need to insert data in list programmatically.

I have one value lets say "myTermStore" which is in "MyCatagory" term set under "MyGroup" term group in managed metadata service.

"myTermStore" value i want to add in my custom list.

I tried following code lines

 SPListItem item = list.Items.Add();
SPField spfld = item.Fields.TryGetFieldByStaticName("MyColumn");
TaxonomyField field = (TaxonomyField)spfld;
TaxonomyFieldValue txFieldValue = new TaxonomyFieldValue(field);
                               txFieldValue.PopulateFromLabelGuidPair("myTermStore");
item[field.Id] = txFieldValue;
item[field.TextField] = "myTermStore";/
however its not storing "myTermStore" value in "MyColumn" field :(


Can anyone please let me know how can I achieve this programmatically ?


Dipti Chhatrapati


Viewing all articles
Browse latest Browse all 11571

Trending Articles