Beispiel #1
0
        protected void grdTimezone_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {  ImageButton lnkDelete = grdTimezone.Rows[e.RowIndex].FindControl("lnkDelete") as ImageButton;
            HiddenField hdfStateid = grdTimezone.Rows[e.RowIndex].FindControl("hdfStateid") as HiddenField;

                if (lnkDelete.CommandArgument.ToString().Trim().ToUpper() == "Inactive".Trim().ToUpper())
                {
                    HiddenField hdfTimezoneid = grdTimezone.Rows[e.RowIndex].FindControl("hdfTimezoneid") as HiddenField;
                    int afctrows;
                    objData = new MasterData();
                    afctrows = objData.Timezone_Delete(Convert.ToInt32(hdfTimezoneid.Value.Trim()));
                    if (afctrows == 103)
                    {
                        lblerrmsg.Text = "Timezone can’t be deleted as is in use by an city";
                        return;
                    }
                    grdfill();
                    divmsg.InnerHtml = "Record deleted successfully.";
                }
                else
                {
                    HiddenField hdfTimezoneid = grdTimezone.Rows[e.RowIndex].FindControl("hdfTimezoneid") as HiddenField;
                    int afctrows;
                    objData = new MasterData();
                    afctrows = objData.Timezone_Activate(Convert.ToInt32(hdfTimezoneid.Value.Trim()));
                    grdfill();
                    divmsg.InnerHtml = "Record activated successfully.";

                }
            }
            catch (Exception ex)
            {
                showerror(ex);
            }
        }