public void SortPartsByCategory(string category)
 {
     GetParts();
     if (category != "" && category != "Show All")
     {
         int id = CategoryCollection.FirstOrDefault(c => c.Name == category).Id;
         PartsCollection = PartsCollection.Where(c => c.CatergoeryId == id).ToList();
     }
 }
        protected override void OnPreRender(EventArgs e)
        {
            Category cat = CategoryManager.GetCategoryByID(CategoryID);

            int catId = 0;

            if (cat != null)
            {
                Category categoryFromList =
                    rootCategories.FirstOrDefault(category => category.CategoryID == cat.ParentCategory.CategoryID);
                if (categoryFromList != null)
                {
                    catId = rootCategories.IndexOf(categoryFromList);
                }
                if (catId >= 0)
                {
                    ScriptManager.RegisterStartupScript(Page, GetType(), "menu_autoOpen",
                                                        string.Format("show_div('div_{0}');", catId), true);
                }
            }

            base.OnPreRender(e);
        }