protected void GvUnits_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "Dlt") { DataTable dt = new DataTable(); StateCode = Session["StateCd"].ToString(); UserName = Session["UsrName"].ToString(); GridViewRow gvrow = (GridViewRow)((Control)e.CommandSource).NamingContainer; DELETE = "D"; Label lblUCode = (Label)gvrow.FindControl("lblUCode"); Label lblUName = (Label)gvrow.FindControl("lblUName"); dt = objDist.DeleteUomBAL(lblUCode.Text, lblUName.Text, DELETE, ConnKey); if (dt.Rows.Count > 0) { objCommon.ShowAlertMessage(dt.Rows[0][0].ToString()); txtUnitCode.Text = ""; txtUnitName.Text = ""; btn_Save.Visible = true; txtUnitCode.Enabled = true; btn_Update.Visible = false; Viewdata(); } else { objCommon.ShowAlertMessage(dt.Rows[0][0].ToString()); txtUnitCode.Text = ""; txtUnitName.Text = ""; btn_Save.Visible = true; txtUnitCode.Enabled = true; btn_Update.Visible = false; } } if (e.CommandName == "Edt") { GridViewRow gvrow = (GridViewRow)((Control)e.CommandSource).NamingContainer; DELETE = "D"; txtUnitCode.Text = ((Label)(gvrow.FindControl("lblUCode"))).Text; txtUnitName.Text = ((Label)(gvrow.FindControl("lblUName"))).Text; txtUnitCode.Enabled = false; btn_Update.Visible = true; btn_Save.Visible = false; } Viewdata(); } catch (Exception ex) { Response.Redirect("~/Error.aspx"); } }