protected void btnCreateSubCategory_Click(object sender, EventArgs e) { if (ddCategory.SelectedIndex > 0) { if (txtSubsubCategory.Text.Length > 0) { if (string.IsNullOrEmpty(Convert.ToString(ViewState["ID"]))) { try { string categoryid = Convert.ToString(ddCategory.SelectedValue); string Subcategoryid = Convert.ToString(ddSubCategory.SelectedValue); string SubsubCatName = txtSubsubCategory.Text.Trim(); int success = 0; success = local_subcategory.AddSubsubCategory(categoryid, Subcategoryid, SubsubCatName); if (success != 0) { clear(); lblMessage.ForeColor = Color.Green; lblMessage.Text = "Sub-sub Category Created Successfully"; BindSubsubCategory(); } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Sub-sub Category Creation Failed"; } } catch (Exception ex) { lblMessage.Text = ex.Message; } } else //Update subcategory { try { string categoryid = Convert.ToString(ddCategory.SelectedValue); string Subcategoryid = Convert.ToString(ddSubCategory.SelectedValue); string SubsubCatName = txtSubsubCategory.Text.Trim(); Int32 subsubid = Convert.ToInt32(ViewState["ID"]); int success = 0; success = local_subcategory.UpdateSubsubCategory(SubsubCatName, Subcategoryid, categoryid, subsubid); if (success != 0) { clear(); lblMessage.ForeColor = Color.Green; lblMessage.Text = "Sub-sub Category Updated Successfully"; BindSubsubCategory(); ViewState["ID"] = null; btnCreateSubCategory.Text = "Create Sub-sub Category"; } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Sub-sub Category Update Failed"; } } catch (Exception ex) { lblMessage.Text = ex.Message; } } } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Enter Sub-sub Category Name"; } } else { lblMessage.ForeColor = Color.Red; lblMessage.Text = "Select Category Name"; } }