Bind Categories in dropdownlist with sitefinity

May 27, 2014

Programmatically populate DropDownList with Taxonomy Categories,

In the sitefinity sometime you need to bind collection list/Categories into repeater grid or drop down.

Below code snippet will helps you for it

TaxonomyManager manager = TaxonomyManager.GetManager();
var taxonomy = manager.GetTaxonomies<HierarchicalTaxonomy>().Where(t => t.Name == "Categories").SingleOrDefault();
var categoryList = taxonomy.Taxa.ToList();
drpEventTypes.DataSource = categoryList;
drpEventTypes.DataTextField = "Title";
drpEventTypes.DataValueField = "Id";