private void AddAgents(MonitorDb monitorDb) { try { monitorDb.DeleteAgentsGroupsByGroupId(_agentGroupId); foreach (GridViewRow gvr in grdAgents.Rows) { var hdnAgentId = Convert.ToInt32(((HiddenField)gvr.FindControl("hdnAgentId")).Value); if (((CheckBox)gvr.FindControl("chkAgent")).Checked == true) { monitorDb.AddAgentsIntoAgentGroup(_agentGroupId, hdnAgentId); } } } catch (Exception ex) { throw new Exception($"Method AddAgents: {ex.Message}"); } }