protected void btnDelete_Click(object sender, EventArgs e) { /////Add Exception handilng try catch change by vishal 21-05-2012 try { foreach (GridViewRow gv in grdvwRequest.Rows) { string gvIDs; // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec"); // If deleteChkBxItem is Checked then ,mapped Current site to this user if (deleteChkBxItem.Checked) { int incidentid; int varSiteid = 0; // Get the Site Id from variable of Label type declare in GridView of grdvwSite gvIDs = ((Label)gv.FindControl("incidentid")).Text.ToString(); incidentid = Convert.ToInt32(gvIDs); // Check if gvIDs is not null if (gvIDs != "") { Incident_mst objInc_mst = new Incident_mst(); objInc_mst = objIncident.Get_By_id(incidentid); objInc_mst.Active = false; objInc_mst.Update(); if (drpSite.SelectedValue != "") { varSiteid = Convert.ToInt32(drpSite.SelectedValue); } if (varSiteid == 0) { BindGridForAllParameter(); } else { BindGridForSelectedParameter(); } } } } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void btnDelete_Click(object sender, EventArgs e) { foreach (GridViewRow gv in grdvwRequest.Rows) { string gvIDs; // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec"); // If deleteChkBxItem is Checked then ,mapped Current site to this user if (deleteChkBxItem.Checked) { int incidentid; int varSiteid=0; // Get the Site Id from variable of Label type declare in GridView of grdvwSite gvIDs = ((Label)gv.FindControl("incidentid")).Text.ToString(); incidentid = Convert.ToInt16(gvIDs); // Check if gvIDs is not null if (gvIDs != "") { Incident_mst objInc_mst= new Incident_mst(); objInc_mst = objIncident.Get_By_id(incidentid); objInc_mst.Active = false ; objInc_mst.Update(); if (drpSite.SelectedValue != "") { varSiteid = Convert.ToInt16(drpSite.SelectedValue); } if (varSiteid == 0) { BindGridForAllParameter(); } else { BindGridForSelectedParameter(); } } } } }