private void BuildSideNavMenu() { //Clear existing nav menu items TreeViewLeftNav.Nodes.Clear(); //Get the subcategory passed in by the query string Category cat = new Category(); cat.GetCategoryByID(Int32.Parse(Request.QueryString["id"])); //Get the parent category for this subcategory Category parentCat = new Category(); parentCat.GetCategoryByID(cat.ParentCategoryID); //Set the parent category TreeNode categoryNode = new TreeNode(); categoryNode.Text = parentCat.Name.ToString(); categoryNode.Expanded = true; TreeViewLeftNav.Nodes.Add(categoryNode); //Get all active categories List<Category> cats = cat.GetAllCategories(true); foreach (Category c in cats) { if (c.ParentCategoryID == parentCat.CategoryID) { TreeNode subCategoryNode = new TreeNode(); subCategoryNode.Text = c.Name.ToString(); subCategoryNode.Value = c.CategoryID.ToString(); categoryNode.ChildNodes.Add(subCategoryNode); } } }
private void categoryChanged() { //Get the selected category object Category cat = new Category(); cat.GetCategoryByID(Convert.ToInt32(TreeViewLeftNav.SelectedValue)); //Set the title for content section subcategoryTitle.InnerText = cat.Name.ToString(); //Get all products for this category Product prod = new Product(); List<Product> prods = prod.GetAllProductsByCategoryID(Convert.ToInt32(TreeViewLeftNav.SelectedValue),true); DataListProducts.DataSource = prods; DataListProducts.DataBind(); }