protected void gvItems_DataBinding(object sender, EventArgs e) { string type = Request["type"]; TermTypes termType = TermTypes.Category; if (!String.IsNullOrEmpty(type)) { termType = BSTerm.GetTermType(type); } List <BSTerm> categories = BSTerm.GetTermsBySubID(termType, 0); List <string> lstNames = new List <string>(); for (int i = 0; i < categories.Count; i++) { string strParents = string.Empty; BSTerm category = categories[i]; while (category.SubID != 0) { BSTerm subCategory = BSTerm.GetTerm(category.SubID); strParents = subCategory.Name + " > " + strParents; } lstNames.Add(strParents + category.Name); } ((GridView)sender).DataSource = categories; if (!IsPostBack) { ddlParentCategory.Items.Insert(0, new ListItem(Language.Admin["None"], "0")); } }
protected void btnDelete_Click(object sender, EventArgs e) { bool bSomeOne = false; bool bCategoriesRemoved = false; for (int i = 0; i < gvItems.Rows.Count; i++) { CheckBox cb = gvItems.Rows[i].FindControl("cb") as CheckBox; if (cb.Checked) { string TermID = (gvItems.Rows[i].FindControl("TermID") as Literal).Text; int iTermID = int.Parse(TermID); List <BSTerm> categories = BSTerm.GetTermsBySubID(TermTypes.Category, iTermID); if (categories.Count == 0) { BSTerm bsTerm = BSTerm.GetTerm(iTermID); if (bsTerm != null) { bsTerm.Remove(); } bCategoriesRemoved = true; } else { bSomeOne = true; } } } if (bSomeOne) { MessageBox1.Message = Language.Admin["CategoryHaveSub"]; MessageBox1.Type = MessageBox.ShowType.Information; } else if (bCategoriesRemoved) { MessageBox1.Message = Language.Admin["CategoryDeleted"]; MessageBox1.Type = MessageBox.ShowType.Information; MessageBox1.Visible = true; gvItems.DataBind(); } }