protected void GvAnimalType_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Dlt") { DataTable dt = new DataTable(); GridViewRow gvrow = (GridViewRow)((Control)e.CommandSource).NamingContainer; DELETE = "D"; Label lblACode = (Label)gvrow.FindControl("lblACode"); Label lblAName = (Label)gvrow.FindControl("lblAName"); dt = objDist.DeleteAnimalBAL(lblACode.Text, lblAName.Text, DELETE, ConnKey); if (dt.Rows.Count > 0) { objCommon.ShowAlertMessage(dt.Rows[0][0].ToString()); txtAnimalTCode.Text = ""; txtAnimalName.Text = ""; btn_Save.Visible = true; btn_Update.Visible = false; Viewdata(); } else { objCommon.ShowAlertMessage(dt.Rows[0][0].ToString()); txtAnimalTCode.Text = ""; txtAnimalName.Text = ""; btn_Save.Visible = true; btn_Update.Visible = false; } Viewdata(); } } catch (Exception ex) { Response.Redirect("~/Error.aspx"); } }