//Handle edit databound public void Edit_Handle(object sender, DataGridCommandEventArgs e) { if ((e.CommandName == "edit")) { TableCell iIdNumber = e.Item.Cells[0]; TableCell iCatName = e.Item.Cells[1]; Panel1.Visible = true; Panel3.Visible = false; AddNewCat.Visible = false; lblnamedis2.Text = "Category Name:"; updatebutton.Visible = true; DelCategory.Visible = false; GroupID.Visible = false; CategoryID.Visible = true; lblheaderform.Text = "Updating Recipe Category #: " + iIdNumber.Text; e.Item.BackColor = System.Drawing.ColorTranslator.FromHtml("#F0E68C"); //This will be the value to be populated into the textboxes string CatName = iCatName.Text; CategoryName.Text = CatName.Substring(0, CatName.IndexOf("(")).Trim(); //Strip off recipe count CategoryID.Value = iIdNumber.Text; } else if ((e.CommandName == "delete")) { TableCell iIdNumber = e.Item.Cells[0]; TableCell iCatName = e.Item.Cells[1]; Panel1.Visible = true; Panel3.Visible = true; AddNewCat.Visible = false; lblnamedis2.Text = "Category Name:"; updatebutton.Visible = false; CategoryID.Visible = true; DelCategory.Visible = true; GroupID.Visible = false; CategoryID.Value = iIdNumber.Text; lblheaderform.Text = "Deleting Recipe Category #: " + iIdNumber.Text; e.Item.BackColor = System.Drawing.ColorTranslator.FromHtml("#F0E68C"); //This will be the value to be populated into the textboxes string CatNamedel = iCatName.Text; CategoryName.Text = CatNamedel.Substring(0, CatNamedel.IndexOf("(")).Trim(); //Strip off recipe count //Instantiate sql params object Blogic myBL = new Blogic(); lblrcdcount2.Text = "The number of recipes belong to " + CategoryName.Text + " category: " + myBL.CategoryCount(int.Parse(iIdNumber.Text)); myBL = null; } }