private void RenderOutput() { if (!ShouldRenderOutput()) { return; } DataTable dt = null; try { dt = GetData(); }catch (Exception ex) { this.ParentPortlet.ShowFeedback(FeedbackType.Error, "Query Failed. Contact portal administrator. " + ex); return; } //if the below is true then at least one row was returned if (dt != null && dt.Rows.Count > 0) { if (_helper.GetSetting("JICSAllowExports").BoolValue) { HttpContext.Current.Session["sqhtml+" + PortalUser.Current.ID.AsGuid + this.ParentPortlet.Portlet.ID.AsGuid] = dt; } if (Convert.ToInt32(_helper.GetSetting("RowLimit", 0).Value) > 0) { dt = dt.AsEnumerable().Take(Convert.ToInt32(_helper.GetSetting("RowLimit", 0).Value)).CopyToDataTable(); } switch (_helper.GetSetting("JICSOutput", "grid").Value) { case "grid": OutputHelper.ConfigureDataGrid(ref dgResults, dt, _helper.GetSetting("JICSGridShowColumnHeadings", false).BoolValue, _helper.GetSetting("JICSGridAltRowColors", false).BoolValue, _helper.GetSetting("JICSGridShowGridlines", false).BoolValue, Convert.ToInt16(_helper.GetSetting("JICSGridCellPadding", 5).Value), _helper.GetSetting("ColumnLabels").Value); dgResults.DataSource = dt; dgResults.DataBind(); dgResults.Visible = true; break; case "xml": preformattedResults.Text = "<pre>" + HttpUtility.HtmlEncode(OutputHelper.RenderXml(dt)) + "</pre>"; break; case "csv": preformattedResults.Text = "<pre>" + OutputHelper.RenderCsv(dt, _helper.GetSetting("JICSGridShowColumnHeadings", false).BoolValue, _helper.GetSetting("ColumnLabels").Value) + "</pre>"; break; case "literal": preformattedResults.Text = OutputHelper.RenderLiteral(dt, _helper.GetSetting("ExportLiteralPattern", "{0}").Value); break; } pnlResults.Visible = true; } else { message2.Visible = true; //If no matching records are found, they are shown a message if (ParentPortlet.AccessCheck("CanAdminQueries") || PortalUser.Current.IsSiteAdmin == true) { message2.InnerHtml = "No results returned by this query.<br />Query text (visible by Query Admin only):<br />" + Regex.Replace(Regex.Replace(_helper.GetSetting("QueryText").Value, "<", "<", RegexOptions.Multiline), ">", ">", RegexOptions.Multiline); } else { message2.InnerHtml = "No results returned by this query."; } return; } }