Esempio n. 1
0
        protected void grdCountry_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                ImageButton lnkDelete = grdCountry.Rows[e.RowIndex].FindControl("lnkDelete") as ImageButton;
                HiddenField hdfStateid = grdCountry.Rows[e.RowIndex].FindControl("hdfStateid") as HiddenField;

                if (lnkDelete.CommandArgument.ToString().Trim().ToUpper() == "Inactive".Trim().ToUpper())
                {
                    HiddenField hdfCountryid = grdCountry.Rows[e.RowIndex].FindControl("hdfCountryid") as HiddenField;
                    int afctrows;
                    objData = new MasterData();
                    afctrows = objData.Country_Delete(Convert.ToInt32(hdfCountryid.Value.Trim()));
                    if (afctrows == 103)
                    {
                        lblerrmsg.Text = "Country can’t be deleted as is in use by an state";
                        return;
                    }
                    grdfill();
                    divmsg.InnerHtml = "Record deleted successfully.";

                }
                else
                {
                    HiddenField hdfCountryid = grdCountry.Rows[e.RowIndex].FindControl("hdfCountryid") as HiddenField;
                    int afctrows;
                    objData = new MasterData();
                    afctrows = objData.Country_Activate(Convert.ToInt32(hdfCountryid.Value.Trim()));
                    grdfill();
                    divmsg.InnerHtml = "Record activated successfully.";
                }
            }
            catch (Exception ex)
            {
                showerror(ex);
            }
        }