protected void btn_Delete_Click(object sender, EventArgs e) { List<SystemUser> oListSystemUser = new List<SystemUser>(); SystemUserBO oSystemUserBO = new SystemUserBO(); Result oResult = new Result(); Boolean bAnyChecked = false; try { oListSystemUser = oListSystemUserForGrid; int[] iArrCheck = new int[oListSystemUser.Count]; for (int i = 0; i < iArrCheck.Length; i++) { iArrCheck[i] = 0; } foreach (GridViewRow oGridRow in Grid_SystemUsers.Rows) { CheckBox oCheckBox = oGridRow.FindControl("deleteRec") as CheckBox; if (oCheckBox.Checked && !oListSystemUser[Grid_SystemUsers.PageIndex * Grid_SystemUsers.PageSize + oGridRow.RowIndex].SystemUserName.ToLower().Equals("administrator")) { iArrCheck[Grid_SystemUsers.PageIndex * Grid_SystemUsers.PageSize + oGridRow.RowIndex] = 1; bAnyChecked = true; } //else //{ // iArrCheck[oGridRow.RowIndex] = 0; //} } if (bAnyChecked) { oResult = oSystemUserBO.SystemUserDelete(oListSystemUser, iArrCheck); if (oResult.ResultIsSuccess) { oListSystemUser = (List<SystemUser>)oResult.ResultObject; //Utils.SetSession(SessionManager.csStoreGridView, oListSystemUser); this.ViewState.Add(SessionManager.csStoreGridView, oListSystemUser); Grid_SystemUsers.DataSource = oListSystemUser; Grid_SystemUsers.DataBind(); lbl_error.ForeColor = Color.Green; lbl_error.Text = oResult.ResultMessage; } else { lbl_error.ForeColor = Color.Red; lbl_error.Text = oResult.ResultMessage; } } else { lbl_error.ForeColor = Color.Red; lbl_error.Text = "Please Select a System User Without Admin."; } } catch (Exception oEx) { lbl_error.ForeColor = Color.Red; lbl_error.Text = "SystemUser Delete Exception."; } }