private void SetupAttendanceExtraQuestions(TimeAdditionalDetail additionalDetails) { try { _pnlAttendance.Visible = true; GetAttendanceLocation(); _ddlAttendanceLocation.SelectedIndex = (int)additionalDetails.AdditionalDetailsLocation; Location_IndexChanged(_ddlAttendanceLocation, _ddlServiceAttendanceLocation); if (_ddlServiceAttendanceLocation.Items.Count > 1) { if(additionalDetails.LAId != null) { if (_ddlServiceAttendanceLocation.Items.FindByValue(Convert.ToString(additionalDetails.LAId)) != null) { _ddlServiceAttendanceLocation.Items.FindByValue(Convert.ToString(additionalDetails.LAId)).Selected = true; } } } TimeServiceClient timeService = null; try { CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = true; timeService = new TimeServiceClient(); AttendanceIndividualSearchReturnValue attendanceIndreturnValue = timeService.AttendanceIndividualSearch(_logonSettings.LogonId, collectionRequest); if (attendanceIndreturnValue.Success) { if (attendanceIndreturnValue.AttendanceIndividual != null) { foreach (AttendanceIndividualSearchItem attendanceIndividual in attendanceIndreturnValue.AttendanceIndividual.Rows) { ListItem item = new ListItem(); item.Text = attendanceIndividual.Code + " - " + attendanceIndividual.Desciption; item.Value = attendanceIndividual.Id.ToString(); _chklstAttendanceIndividuals.Items.Add(item); } } } else { throw new Exception(attendanceIndreturnValue.Message); } } catch (Exception ex) { throw ex; } finally { if (timeService != null) { if (timeService.State != System.ServiceModel.CommunicationState.Faulted) timeService.Close(); } } // Uncheck all the previously selected items. for (int i = 0; i < _chklstAttendanceIndividuals.Items.Count; i++) { _chklstAttendanceIndividuals.Items[i].Selected = false; } // Check the Attendance Individuals. foreach (int individualId in additionalDetails.AttendanceIndividuals) { for (int k = 0; k < this._chklstAttendanceIndividuals.Items.Count; k++) { if (Convert.ToInt32(this._chklstAttendanceIndividuals.Items[k].Value) == individualId) { _chklstAttendanceIndividuals.Items[k].Selected = true; break; } } } } catch (Exception ex) { throw ex; } }