/// <summary>
        /// Renders the entire query results in the inner table.
        /// </summary>
        /// <param name="queryDef">The definition of the query that was executed.</param>
        /// <param name="renderedRows">Rendered query results.</param>
        /// <param name="hw">The <c>HtmlTextWriter</c> to write to.</param>
        ///
        void RenderQueryResults(QueryDefinition queryDef,
                                List <RenderedCell[]> renderedRows,
                                HtmlTextWriter hw)
        {
            // get the column definitions
            IList <ColumnDefinition> columnDefs = queryDef.Columns;

            //Get the column index to sort on and sort order
            int  sortColumnIndex;
            bool sortAscending = GetSortIndex(out sortColumnIndex);

            // sort <renderedRows> if so specified
            if ((sortColumnIndex >= 0) && (sortColumnIndex < queryDef.Columns.Count))
            {
                queryDef.SortRenderedRows(renderedRows, sortColumnIndex, sortAscending);
            }

            // render the "<table>" element and its contents
            hw.AddAttribute(HtmlTextWriterAttribute.Class, "ms-summarystandardbody");
            // skipped: id=TABLE1 dir=None
            hw.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            hw.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "1");
            hw.AddAttribute(HtmlTextWriterAttribute.Style, "width:100%;");
            hw.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            using (new HtmlBlock(HtmlTextWriterTag.Table, 1, hw))
            {
                // render the header row
                hw.AddAttribute(HtmlTextWriterAttribute.Class, "ms-viewheadertr");
                hw.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
                using (new HtmlBlock(HtmlTextWriterTag.Tr, 0, hw))
                {
                    // render the column headers
                    int columnIndex = 0;
                    foreach (ColumnDefinition columnDef in columnDefs)
                    {
                        bool?ascendingSort;
                        if (sortColumnIndex == columnIndex)
                        {
                            ascendingSort = sortAscending;
                        }
                        else
                        {
                            ascendingSort = null;
                        }
                        RenderColumnHeader(columnDef, columnIndex, ascendingSort, hw);

                        columnIndex++;
                    }
                }

                //If No Items Found
                if (renderedRows.Count == 0)
                {
                    using (new HtmlBlock(HtmlTextWriterTag.Tr, 1, hw))
                    {
                        hw.AddAttribute(HtmlTextWriterAttribute.Colspan,
                                        columnDefs.Count.ToString(CultureInfo.InvariantCulture));
                        using (new HtmlBlock(HtmlTextWriterTag.Td, 1, hw))
                        {
                            SlkError slkError
                                = new SlkError(ErrorType.Info,
                                               Constants.Space +
                                               Constants.Space +
                                               PageCulture.Resources.AlwpNoItemFound);
                            WebParts.ErrorBanner.RenderErrorItems(hw, slkError);
                        }
                    }
                }
                else
                {
                    // render the rows
                    int rowIndex = 0;
                    foreach (RenderedCell[] renderedRow in renderedRows)
                    {
                        // render the "<tr>"; note that every other row is shaded ("ms-alternating")
                        hw.AddAttribute(HtmlTextWriterAttribute.Class,
                                        (((rowIndex & 1) == 0) ? "ms-alternating" : ""));
                        using (new HtmlBlock(HtmlTextWriterTag.Tr, 1, hw))
                        {
                            // set <webNameRenderedCell> to any cell in the row which is of type
                            // WebNameRenderedCell, i.e. which refers to a SharePoint Web site,
                            // or null if none
                            WebNameRenderedCell webNameRenderedCell = null;
                            Guid learnerAssignmentGUID = Guid.Empty;
                            foreach (RenderedCell renderedCell in renderedRow)
                            {
                                if (webNameRenderedCell == null)
                                {
                                    webNameRenderedCell = renderedCell as WebNameRenderedCell;
                                }

                                if (learnerAssignmentGUID == Guid.Empty)
                                {
                                    if (renderedCell.Id != null)
                                    {
                                        if (renderedCell.Id.ItemTypeName == Schema.LearnerAssignmentItem.ItemTypeName)
                                        {
                                            learnerAssignmentGUID = SlkStore.GetLearnerAssignmentGuidId(renderedCell.Id);
                                        }
                                    }
                                }

                                if (webNameRenderedCell != null && learnerAssignmentGUID != Guid.Empty)
                                {
                                    break;
                                }
                            }

                            // render the cells in this row
                            int columnIndex = 0;
                            foreach (RenderedCell renderedCell in renderedRow)
                            {
                                ColumnDefinition columnDef = columnDefs[columnIndex];
                                hw.AddAttribute(HtmlTextWriterAttribute.Class, "ms-vb2");
                                if (!columnDef.Wrap)
                                {
                                    hw.AddAttribute(HtmlTextWriterAttribute.Nowrap, "true");
                                }
                                using (new HtmlBlock(HtmlTextWriterTag.Td, 1, hw))
                                {
                                    if (columnDef.Title.Equals(PageCulture.Resources.AlwpFileSubmissionColumnTitle))
                                    {
                                        RenderFileSubmissionCell(renderedCell, webNameRenderedCell, learnerAssignmentGUID, hw);
                                    }
                                    else
                                    {
                                        RenderColumnCell(renderedCell, webNameRenderedCell, hw, SlkStore);
                                    }
                                }

                                columnIndex++;
                            }
                        }
                        rowIndex++;
                    }
                }
            }
        }