Create a HierarchicalTaxon Parent Ref

Posted by Community Admin on 04-Aug-2018 03:35

Create a HierarchicalTaxon Parent Ref

All Replies

Posted by Community Admin on 01-Aug-2012 00:00

### EDIT ###
Got it, for anyone else, make sure to set the Taxonomy property of your new category to be the category.
(this one)

this.PageTaxonomyManager.GetTaxonomy<HierarchicalTaxonomy>(TaxonomyManager.CategoriesTaxonomyId);



If I create a new HierarchicalTaxon object, how do I go about setting its parent?

I'm trying something like this, but I get object ref error on SaveChanges

foreach (var c in children)
            
                //c.ItemParent = parentCategory;
                //c.Parent = parentCategory;
                           parentCategory.Subtaxa.Add(c);
 
                //this.Category.Taxa.Add(c);
                this.PageTaxonomyManager.SaveChanges();
          
(various combos)

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 58:                 c.Parent = parentCategory;
Line 59:                 this.Category.Taxa.Add(c);
Line 60:                 this.PageTaxonomyManager.SaveChanges();

This thread is closed