0

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.

1 Answer 1

1

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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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