Exemplo n.º 1
0
    protected void GvBreed_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "Dlt")
            {
                DataTable   dt         = new DataTable();
                GridViewRow gvrow      = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                Label       lblBreedCd = (Label)gvrow.FindControl("lblBreedCd");
                dt = objDist.DeleteBreedBAL(ddl_AnimalType.SelectedValue.ToString(), lblBreedCd.Text, ConnKey);
                if (dt.Rows.Count > 0)
                {
                    objCommon.ShowAlertMessage(dt.Rows[0][0].ToString());
                    txtBreedCode.Text      = "";
                    ddl_AnimalType.Enabled = true;
                    txtBreedName.Text      = "";
                    btn_Update.Visible     = false;
                    btn_Save.Visible       = true;
                }
                else
                {
                    ddl_AnimalType.Enabled = true;
                    btn_Update.Visible     = false;
                    btn_Save.Visible       = true;
                    objCommon.ShowAlertMessage(dt.Rows[0][0].ToString());
                }
                Viewdata();
            }

            if (e.CommandName == "Edt")
            {
                GridViewRow gvrow = (GridViewRow)((Control)e.CommandSource).NamingContainer;
                txtBreedCode.Text            = ((Label)(gvrow.FindControl("lblBreedCd"))).Text;
                txtBreedName.Text            = ((Label)(gvrow.FindControl("lblBreedNm"))).Text;
                ddl_AnimalType.SelectedValue = ((Label)(gvrow.FindControl("lblAnimalTyeCd"))).Text;
                ddl_AnimalType.Enabled       = false;
                txtBreedCode.Enabled         = false;
                btn_Update.Visible           = true;
                btn_Save.Visible             = false;
            }
        }
        catch (Exception ex)
        {
            ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString());
            Response.Redirect("~/Error.aspx");
        }
    }