More in this section
Forums / Sitefinity SDK / Populate Dropdown with values from categories (taxonomy)

Populate Dropdown with values from categories (taxonomy)

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Marco
    Marco avatar
    1 posts
    Registered:
    11 Dec 2011
    23 Dec 2011
    Link to this post
    Hi,

    I'm a newbie. i got a three level drop down and i want to populate it with the values. currently the images/videos are categorized from type of "businesstype" as parent ,"country" as child of businesstype, then "state" the last child.

    please see my sample code:

    TaxonomyManager manager = TaxonomyManager.GetManager();
    var taxonomy = manager.GetTaxonomies<HierarchicalTaxonomy>().Where(t => t.Name == "Categories").SingleOrDefault();
    var details = taxonomy.Taxa.ToList();
    foreach (HierarchicalTaxon taxon in details)
    {
    var li = new ListItem(taxon.Title, taxon.Title);
    ddlList.Items.Add(li);
    }

    i can get the whole list but i have no way to segregate them by parent to child. i hope youcould give a snipper on how to do it. thanks.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    26 Dec 2011
    Link to this post
    Hello,

    HierarchicalTaxon has a property parent that you can use.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

2 posts, 0 answered