protected void grdItemCategoryMaster_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("ADD")) { DropDownList ddlNewCategoryGroupCode = (DropDownList)grdItemCategoryMaster.FooterRow.FindControl("ddlNewCategoryGroupCode"); DropDownList ddlNewCanteenName = (DropDownList)grdItemCategoryMaster.FooterRow.FindControl("ddlNewCanteenName"); TextBox txtNewItemCategoryName = (TextBox)grdItemCategoryMaster.FooterRow.FindControl("txtNewItemCategoryName"); CheckBox ChStatusNew = (CheckBox)grdItemCategoryMaster.FooterRow.FindControl("ChStatusNew"); DropDownList ddlNewStartTime = (DropDownList)grdItemCategoryMaster.FooterRow.FindControl("ddlNewStartTime"); DropDownList ddlNewEndTime = (DropDownList)grdItemCategoryMaster.FooterRow.FindControl("ddlNewEndTime"); if (IsValid) { //errNumber = -1; try { objBusinessClass = new BusinessLayer.BusinessClass(); objML_ItemCategoryMaster = new ML_ItemCategoryMaster(); objML_ItemCategoryMaster.CategoryGroupCode = Convert.ToInt32(ML_Common.clean(ddlNewCategoryGroupCode.SelectedValue)); objML_ItemCategoryMaster.CanteenCode = Convert.ToInt32(ML_Common.clean(ddlNewCanteenName.SelectedValue)); objML_ItemCategoryMaster.ItemCategoryName = ML_Common.clean(txtNewItemCategoryName.Text); objML_ItemCategoryMaster.StartTime = Convert.ToDateTime(ML_Common.clean(ddlNewStartTime.SelectedValue)); objML_ItemCategoryMaster.EndTime = Convert.ToDateTime(ML_Common.clean(ddlNewEndTime.Text)); if (ChStatusNew.Checked) { objML_ItemCategoryMaster.ItemCategoryActive = 1; } else { objML_ItemCategoryMaster.ItemCategoryActive = 0; } int obhReturn = objBusinessClass.AddItemCategoryMaster(objML_ItemCategoryMaster); if (obhReturn == 1) { lblMsg.Visible = true; lblMsg.Text = "Record Saved Successfully"; FillGrid(); } else if (obhReturn == 2) { lblMsg.Text = "Record Already Exists!"; lblMsg.Visible = true; } } catch (SqlException sqlExc) { // LogManager.LogManager.WriteErrorLog(sqlExc); SqlException sqlEt = sqlExc; return; } catch (Exception ex) { Exception exc = ex;// Exception exc=ex;// LogManager.LogManager.WriteErrorLog(ex); } } } }