protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Dlt") { DataTable dt = new DataTable(); StateCode = Session["StateCd"].ToString(); UserName = Session["UsrName"].ToString(); Flag_IUP = "D"; GridViewRow gvrow = (GridViewRow)((Control)e.CommandSource).NamingContainer; Label lblInsCode = (Label)gvrow.FindControl("lblInsCode"); Label lblRegf = (Label)gvrow.FindControl("lblRegf"); dt = objDist.DeleteRegBAL(lblInsCode.Text, ViewState["AnimalTypeCode"].ToString(), lblRegf.Text, Flag_IUP, ConnKey); if (dt.Rows.Count > 0) { objCommon.ShowAlertMessage(dt.Rows[0][0].ToString()); txtregfee.Text = ""; btn_Save.Visible = true; btn_Update.Visible = false; ddlAnimal.Enabled = true; BindAnimal(); Viewdata(); } } } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString()); Response.Redirect("~/Error.aspx"); } }