Friday, March 30, 2012

Problems with the Web ReportViewer Control

Problems with the Web ReportViewer Control

I'm using SQL Server 2005 Reporting Services Sept CTP and Visual Studio 2005 RC to develop an ASP.NET application. On one of my web forms I have placed the web ReportViewer control so that I can display reports from Reporting Services.

The .aspx code is:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="ReportViewer.aspx.cs" Inherits="ReportViewer" %>

<%@. Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>ReportViewer</title>

</head>

<body>

<form id="formReportViewer" runat="server">

<div>

<asp:Panel ID="PanelDisplayReport" runat="server" Height="100%" Width="100%">

<rsweb:reportviewer id="ReportViewerDisplayReport" runat="server" bordercolor="Navy" borderstyle="Solid" borderwidth="1px" height="100%" tooltip="Display Report" width="100%" Font-Names="Verdana" Font-Size="8pt" ProcessingMode="Remote">

</rsweb:reportviewer>

</asp:Panel>

</div>

</form>

</body>

</html>

The .aspx code-behind (in C#) is:

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class ReportViewer : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

this.ReportViewerDisplayReport.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;

this.ReportViewerDisplayReport.ToolTip = "/AdventureWorks Sample Reports/Company Sales";

this.ReportViewerDisplayReport.ZoomPercent = 90;

this.ReportViewerDisplayReport.ServerReport.DisplayName = "/AdventureWorks Sample Reports/Company Sales";

this.ReportViewerDisplayReport.ServerReport.ReportPath = @."/AdventureWorks Sample Reports/Company Sales";

this.ReportViewerDisplayReport.ServerReport.ReportServerUrl = new Uri(@."http://localhost/ReportServer");

}

}

As you can see, this is a very simply web form that is simply trying to display one of the reports from the AdventureWorks sample database and reports.

The problem is that the report will not display in the ReportViewer control. When I request the page, I see the ReportViewer's toolbar but not the actual report. I initially see the "Report is being generated" message in the control, where the report would normally be displayed. But, after the report is generated, no report, just the toolbar.

Anyway, does any one have any suggestions as to what's wrong?

Is there a bug in the ReportViewer control (for web forms) in Visual Studio 2005 RC?

Anything else???

Thanks in advance.


The problem is that height is set to 100% and doctype is set to XHTML. Either set the height to a fixed size (not a percent) or remove the line that sets doctype to XHTML.|||Thanks for this. I spent a couple of hours on this, I could have spent many more.|||You can also fix this problem by rendering the report synchronously. The control displays the report differently based on the method of rendering and calculates the actual height on the fly. When rendered synchronously, the calculated height is 0px, so nothing shows.

No comments:

Post a Comment