Ejemplo n.º 1
0
    protected void GvSate_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 lblSCode = (Label)gvrow.FindControl("lblSCode");
                Label lblSName = (Label)gvrow.FindControl("lblSName");
                dt = objDist.DeleteStateBAL(lblSCode.Text, lblSName.Text, DELETE, ConnKey);
                if (dt.Rows.Count > 0)
                {
                    // if (dt.Rows[0][0].ToString() == "3")
                    //{
                    //string aa = "Deleted Successfully";
                    objCommon.ShowAlertMessage(dt.Rows[0][0].ToString());
                    txtstateCode.Text = "";
                    txtstateName.Text = "";
                    Viewdata();

                    // }
                }
                else
                {
                    objCommon.ShowAlertMessage(dt.Rows[0][0].ToString());
                    txtstateCode.Text = "";
                    txtstateName.Text = "";
                }
            }

            if (e.CommandName == "Edt")
            {
                GridViewRow gvrow = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                DELETE            = "D";
                txtstateCode.Text = ((Label)(gvrow.FindControl("lblSCode"))).Text;
                txtstateName.Text = ((Label)(gvrow.FindControl("lblSName"))).Text;

                txtstateCode.Enabled = false;
                btn_Update.Visible   = true;
                btn_Save.Visible     = false;
            }
            Viewdata();
        }
        catch (Exception ex)
        {
            ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString());
            Response.Redirect("~/Error.aspx");
        }
    }