protected void GvData_RowCommand(object sender, GridViewCommandEventArgs e) { try { DataTable dtInfo = new DataTable(); GridViewRow gvrow = (GridViewRow)(((ImageButton)e.CommandSource).NamingContainer); hdUniqueId.Value = GvData.DataKeys[gvrow.RowIndex].Value.ToString(); // fill the Location information for edit if (e.CommandName == "EditEntry") { objValidateData.ClearAllInputField(pnlDataEntry); dtInfo = objLtmsService.GetLotteryTypeDtlById(Convert.ToInt64(hdUniqueId.Value)); if (dtInfo.Rows.Count > 0) { txtLotteryType.Text = dtInfo.Rows[0]["LotteryType"].ToString(); } dtInfo.Dispose(); pnlDataEntry.Visible = true; pnlDataDisplay.Visible = false; btnSave.Text = "Update"; // lblSubHead.Text = "Update Location Information"; txtLotteryType.Focus(); } //Delete the location information if (e.CommandName == "DeleteEntry") { if (objMenuOptions.AllowDelete == false) { ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('You do not have proper privilege for deleting a record.');", true); return; } //dtInfo = objMstLocation.IsChildRecordExistForLocation(hdUniqueId.Value); //if (dtInfo.Rows.Count > 0) //{ // ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('This data already exist in another dependent table. Deletion failed !');", true); // dtInfo.Dispose(); // return; //} bool isDeleted = objLtmsService.DeleteInLotteryType(Convert.ToInt64(hdUniqueId.Value)); if (isDeleted == true) { BindGvData(); ScriptManager.RegisterStartupScript(this, GetType(), "MyMsg", "alert('Lottery Type information deleted.');", true); // ResetSearchFilte(); //BindLocationInformationDetails(cmbSearch.SelectedValue.ToString(), "", cmbSearch.SelectedValue.ToString(), true); } } dtInfo.Dispose(); } catch (Exception Ex) { objValidateData.SaveSystemErrorLog(Ex, Request.UserHostAddress); var message = new JavaScriptSerializer().Serialize("Some Error has occurred while performing your activity. Please contact the System Administrator for further assistance."); var script = string.Format("alert({0});", message); ScriptManager.RegisterClientScriptBlock(this, GetType(), "", script, true); } }