protected void OnDDListSelectionChanged_Click(object sender, EventArgs e) { ProductController productController = new ProductController(); CategoryController categoryController = new CategoryController(); string category = ((DropDownList)sender).SelectedItem.Text; dgProducts.DataSourceID = null; if (!string.IsNullOrEmpty(category)) { dgProducts.DataSource = productController.SelectByCategoryId( categoryController.GetIdByName(category)); } dgProducts.DataBind(); }
protected void LinkButton_Command(object sender, CommandEventArgs e) { switch (e.CommandName) { case "New": { Server.Transfer("AddCategoryPage.aspx"); } break; case "Edit": { Session["categoryID"] = e.CommandArgument; Server.Transfer("AddCategoryPage.aspx"); } break; case "Delete": { CategoryController categoryController = new CategoryController(); int id = Convert.ToInt32(e.CommandArgument); categoryController.RemoveCategory(id); Server.Transfer("ChocolateManagement.aspx"); } break; } }