protected void btndelete_Click(object sender, EventArgs e) { try { string selectid = string.Empty; Boolean deletestatus = false; for (int i = 0; i < gvcampaign.Rows.Count; i++) { if (gvcampaign.Rows[i].RowType == DataControlRowType.DataRow) { CheckBox chk = (CheckBox)gvcampaign.Rows[i].Cells[0].FindControl("CheckBox1"); Label lblEmpID = (Label)gvcampaign.Rows[i].Cells[0].FindControl("lblEmpID"); if (chk.Checked) { DataTable dtplantype = new DataTable(); if (selectid == "") { if (!selectid.Contains(lblEmpID.Text.ToString())) { selectid = lblEmpID.Text; dtplantype = objBL_Common.plantypedetails("PK_CampaignID", "EC_Campaign", "FK_UserID in (" + lblEmpID.Text + ")"); if (dtplantype.Rows.Count > 0) deletestatus = true; else { objBL_Common = new BL_Common(); string emailid = "'" + gvcampaign.Rows[i].Cells[5].Text + "'"; objBL_Common.AccessDeletAlleCampaign("EC_InviteUser", "Emailid", emailid); objBL_Common = new BL_Common(); objBL_Common.AccessDeletAlleCampaign("EC_UserLogin", "PK_UserID", lblEmpID.Text); } } } else { if (!selectid.Contains(lblEmpID.Text.ToString())) { selectid = selectid + "," + lblEmpID.Text; dtplantype = objBL_Common.plantypedetails("PK_CampaignID", "EC_Campaign", "FK_UserID in (" + lblEmpID.Text + ")"); if (dtplantype.Rows.Count > 0) deletestatus = true; else { objBL_Common = new BL_Common(); string emailid = "'" + gvcampaign.Rows[i].Cells[5].Text + "'"; objBL_Common.AccessDeletAlleCampaign("EC_InviteUser", "Emailid", emailid); objBL_Common = new BL_Common(); objBL_Common.AccessDeletAlleCampaign("EC_UserLogin", "PK_UserID", lblEmpID.Text); } } } } } } if (selectid == "") ClientScript.RegisterStartupScript(Page.GetType(), "mykey28", "alert('Select at least one record !');", true); else { if (deletestatus == true) ClientScript.RegisterStartupScript(Page.GetType(), "mykey29", "alert('You cannot delete these user, Since it is referred by campaign!');", true); this.Bindrolegrid(); } } catch (Exception ex) { New_EmailCampaign.App_Code.GlobalFunction.StoreLog("InviteUserList.aspx:btndelete_Click() - " + ex.Message); } }