private bool saveMemberRoleUpdates() { bool bSuccess = true; try { CheckBox cbxMemberRoleActive; TextBox txtbRefUserRoleID; List <vMemberRoleModel> memberRoles = new List <vMemberRoleModel>(); for (int i = 0; i < RolesGridView.Rows.Count; i++) { cbxMemberRoleActive = (CheckBox)RolesGridView.Rows[i].FindControl("IsMemberRoleActive"); txtbRefUserRoleID = (TextBox)RolesGridView.Rows[i].FindControl("RefMemberRoleID"); if (!string.IsNullOrEmpty(txtbRefUserRoleID.Text)) { var memberRoleMatch = GlobalLists.MemberRoles.Where(entity => entity.RefMemberRoleID == Int32.Parse(txtbRefUserRoleID.Text.Trim())).FirstOrDefault(); if (memberRoleMatch != null) { //check if the value changed and only add if it does if (memberRoleMatch.IsMemberRoleActive != cbxMemberRoleActive.Checked) { vMemberRoleModel memRole = new vMemberRoleModel(); memRole.RefMemberRoleID = Int32.Parse(txtbRefUserRoleID.Text.Trim()); memRole.IsMemberRoleActive = cbxMemberRoleActive.Checked; memberRoles.Add(memRole); } } //RefRole being activated for the the first time for this member, insert into MemberRole (associate with this member) else if (cbxMemberRoleActive.Checked) { vMemberRoleModel memRole = new vMemberRoleModel(); memRole.RefMemberRoleID = Int32.Parse(txtbRefUserRoleID.Text.Trim()); memRole.IsMemberRoleActive = cbxMemberRoleActive.Checked; memberRoles.Add(memRole); } } } if (memberRoles.Count > 0) { string saltShakerUserName = string.Format("AMSA\\{0}", SaltShakerSession.UserId); bSuccess = Members.UpdateMemberRoles(int.Parse(SaltShakerSession.selectedMemberID), memberRoles, saltShakerUserName); if (bSuccess) { //give it a second to update GlobalUtils.WaiTTime(); renderRolesGridView(SaltShakerSession.selectedMemberID); ClearAllDirtyFlags(); ShowMessage("MemberRoles " + GlobalMessages.sMSG_UPDATE_SUCCESS); } else { ShowMessage(string.Format(GlobalMessages.sMSG_WARNING, "MemberRoles update appears to have failed. Please contact support for assistance [MemberRoleSave]")); } } } catch (Exception saveEx) { ShowMessage(string.Format(GlobalMessages.sMSG_WARNING, "your MemberRoles update appears to have failed. Please contact support for assistance " + saveEx)); } return(bSuccess); }