private void SetupAdvocacyExtraQuestions(TimeAdditionalDetail additionalDetails) { try { _pnlAdvocacy.Visible = true; GetAdvocacyLocation(); _ddlAdvocacyLocation.SelectedIndex = (int)additionalDetails.AdditionalDetailsLocation; Location_IndexChanged(_ddlAdvocacyLocation, _ddlServiceAdvocacyLocation); if (_ddlServiceAdvocacyLocation.Items.Count > 1) { if (additionalDetails.LAId != null) { if (_ddlServiceAdvocacyLocation.Items.FindByValue(Convert.ToString(additionalDetails.LAId)) != null) { _ddlServiceAdvocacyLocation.Items.FindByValue(Convert.ToString(additionalDetails.LAId)).Selected = true; } } } TimeServiceClient timeService = null; try { CollectionRequest collectionRequest = new CollectionRequest(); collectionRequest.ForceRefresh = true; timeService = new TimeServiceClient(); AdvocacyTypeSearchReturnValue advocacyTypeReturnValue = timeService.AdvocacyTypeSearch(_logonSettings.LogonId, collectionRequest); if (advocacyTypeReturnValue.Success) { if (advocacyTypeReturnValue.AdvocacyType != null) { foreach (AdvocacyTypeSearchItem advocacyType in advocacyTypeReturnValue.AdvocacyType.Rows) { ListItem item = new ListItem(); item.Text = advocacyType.Code + " - " + advocacyType.Desciption; item.Value = advocacyType.Id.ToString(); _chklstHearingType.Items.Add(item); } } } else { throw new Exception(advocacyTypeReturnValue.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 < _chklstHearingType.Items.Count; i++) { _chklstHearingType.Items[i].Selected = false; } // Check the Attendance Individuals. foreach (int advocacyTypeId in additionalDetails.AdvocacyTypes) { for (int k = 0; k < this._chklstHearingType.Items.Count; k++) { if (Convert.ToInt32(this._chklstHearingType.Items[k].Value) == advocacyTypeId) { _chklstHearingType.Items[k].Selected = true; break; } } } } catch (Exception ex) { throw ex; } }