Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a list with a taxonomy column.

I have made SPMetal classes to work with my site.

But SPMetal doesn't create the property for taxonomy column, so I have extended my class by the ICustomMapping interface:

    public TaxonomyFieldValue Branch
    {
        get { return _branch; }
        set
        {
            if ((value == _branch))
                return;

            this.OnPropertyChanging("Branch", _branch);
            _branch = value;
            this.OnPropertyChanged("Branch");
        }

Now I have the following problem: I need to insert a new item on my list and I would like to use SPMetal:

        RequestItem newRequest = new RequestItem
                                      {
                                          Branch = taxonomyField,
                                          CompanyEmailAddress = txtCompanyEmail.Text,
                                          Name = txtName.Text,
                                          Phone = txtPhone.Text,
                                          RequestType = RequestType.Entry,
                                          Status = Status.SUBMITTED,
                                          Surname = txtSurname.Text,
                                          //UserIdId = usr.ID,
                                      };

the value for "taxonomyField" comes from the form and I don't know how can I get it from the TaxonomyWebTaggingControl.

share|improve this question
add comment

1 Answer

The TaxonomyWebTaggingControl has a property Text. This will return the value in the format Label|Guid. To get the label, the code will be like this (from the top of my head)

TaxonomyFieldValueCollection tagValues = new TaxonomyFieldValueCollection();
tagValues.PopulateFromLabelGuidPairs(TaxonomyWebTaggingControlName.Text);
string labelValue=tagValues[0].Label;
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.