protected List <TASK_STATUS> UpdateAlertTaskList(List <TASK_STATUS> alertTaskList) { // create task for each location and/or update existing task TASK_STATUS task = null; int taskSeq = 0; bool isNew = false; RadComboBox ddl = null; HiddenField hf = null; foreach (GridDataItem item in rgAlertTaskList.Items) { hf = (HiddenField)item.FindControl("hfTaskID"); ddl = (RadComboBox)item.FindControl("ddlResponsible"); if (string.IsNullOrEmpty(hf.Value)) // create new { isNew = true; task = new TASK_STATUS(); hf = (HiddenField)item.FindControl("hfLocationTZ"); task = EHSIncidentMgr.CreateEmptyTask(LocalIncident.INCIDENT_ID, ((int)SysPriv.notify).ToString(), ++taskSeq, WebSiteCommon.LocalTime(DateTime.UtcNow, hf.Value)); task.RECORD_TYPE = (int)TaskRecordType.HealthSafetyIncident; hf = (HiddenField)item.FindControl("hfLocation"); task.RECORD_SUBID = Convert.ToDecimal(hf.Value); task.RECORD_ID = LocalIncident.INCIDENT_ID; alertTaskList.Add(task); localCtx.AddToTASK_STATUS(task); } else { isNew = false; task = alertTaskList.Where(l => l.TASK_ID.ToString() == hf.Value).FirstOrDefault(); // existing } // task.DESCRIPTION = tbAlertDesc.Text; task.DETAIL = tbComments.Text; task.DUE_DT = rdpDueDate.SelectedDate; if (!string.IsNullOrEmpty(ddl.SelectedValue)) { task.RESPONSIBLE_ID = Convert.ToDecimal(ddl.SelectedValue); } else { alertTaskList.Remove(task); localCtx.DeleteObject(task); } } return(alertTaskList); }