/// <summary>
        /// Creates the set of results from the search response.
        /// </summary>
        /// <param name="output">The results from the search.</param>
        /// <returns>A populated CourseSearchResults object.</returns>
        private CourseSearchResults CreateCourseSearchResults(CourseListOutput output)
        {
            CourseSearchResults results = new CourseSearchResults();

            if (output != null &&
                output.CourseListResponse != null)
            {
                if (output.CourseListResponse.CourseDetails != null)
                {
                    foreach (CourseStructure course in output.CourseListResponse.CourseDetails)
                    {
                        results.Add(CreateResult(course));
                    }
                }

                if (output.CourseListResponse.MatchingLDCS != null)
                {
                    results.MatchingLDCSCodes = new List <LDCSCode>();
                    foreach (CourseListResponseStructureMatchingLDCS ldcsCode in output.CourseListResponse.MatchingLDCS)
                    {
                        results.MatchingLDCSCodes.Add(CreateLDCS(ldcsCode));
                    }
                }
            }

            return(results);
        }
        /// <summary>
        /// Gets the search results and displays on the screen.
        /// </summary>
        /// <param name="criteria">The course search criteria.</param>
        /// <param name="sortBy">The column to sort by.</param>
        /// <param name="recordsPerPage">The number of records per page.</param>
        /// <param name="pageNo">The page number</param>
        private void PopulateData(SearchCriteriaStructure criteria, string sortBy, string recordsPerPage, string pageNo)
        {
            // fire the web service to get some results
            CourseListOutput output = GetResults(criteria, sortBy, recordsPerPage, pageNo);

            if (output != null)
            {
                CourseSearchResults results = CreateCourseSearchResults(output);

                if (results.Any())
                {
                    int totalPages;
                    {
                        int.TryParse(output.CourseListResponse.ResultInfo.NoOfPages, out totalPages);
                    }

                    int currentPageNo;
                    {
                        int.TryParse(output.CourseListResponse.ResultInfo.PageNo, out currentPageNo);
                    }

                    int totalRecords;
                    {
                        int.TryParse(output.CourseListResponse.ResultInfo.NoOfRecords, out totalRecords);
                    }

                    divResults.Visible = true;

                    // only need to display compare button if we have more than 1 record
                    cmdCompare.Visible = results.Count() > 1;
                    int pageSize;
                    int.TryParse(recordsPerPage, out pageSize);

                    ResultsOverviewLabel.Text = String.Format(Constants.StringFormats.ResultsOverviewStringFormat, currentPageNo, totalPages, totalRecords);

                    SetupPageNavButtons(totalPages, currentPageNo);

                    CourseResultsRepeater.DataSource = results;
                    CourseResultsRepeater.DataBind();

                    if (results.MatchingLDCSCodes != null &&
                        results.MatchingLDCSCodes.Count > 1)
                    {
                        MatchingLDCSCodesRepeater.DataSource = results.MatchingLDCSCodes;
                        MatchingLDCSCodesRepeater.DataBind();
                    }
                }
                else
                {
                    DisplayNoResults();
                }
            }
            else
            {
                DisplayNoResults();
            }
        }