Search code examples
asp.netsql-servervisual-studio-2010reporting-servicesssrs-tablix

Visual Studio 2010, Local SSRS Report Viewer 14, Preview is empty, but Export and Print work fine


Report Viewer Preview displays empty, but Export and Print work fine.

I'm just about at my wits' end over this. I'm needing to make changes to an existing SSRS Report, and while all of the pieces seem to be doing their job, the final result is an empty report, even through the Report Viewer is fetching the right data for the report. (footnote:The report was called "ByGroup", but I'm changing pieces of it to "ByFields" to ensure that the existing report could still function on its own. This may be the cause of some of the issues, but I've tried to be careful to avoid that.)

The project uses Data Tables declared in a separate .xsd file held in the App_Code folder of a website. The data table calls a stored procedure, and the columns are all present, and the Fill and GetData methods are in place. Using the Data Table "Preview Data" option, we can verify that the Data Table is correct, and returns the correct data. We can provide more data to this end if it is relevant.

Our report's .aspx file has the correct Register tag for Report Viewer 14:

<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>

We are using an ObjectDataSource that links to the TableAdapter definition:

<asp:ObjectDataSource ID="EventListingByGroup_DataInstance" runat="server" 
    OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
    TypeName="AEMSReports.dsAEMSReportsTableAdapters.AEMSReports_056_EventListingByFieldsTableAdapter">

The <SelectParameters> element accurately declares all of the parameters to feed the stored procedure.

The ReportViewer is defined as follows:

<rsweb:ReportViewer ID="rvEventListingByGroup" runat="server" Font-Names="Verdana" 
    Font-Size="8pt" Height="100%" Width="850px" AsyncRendering="False" 
    ClientIDMode="AutoID" InternalBorderColor="204, 204, 204" InternalBorderStyle="Solid" 
    InternalBorderWidth="1px" ToolBarItemBorderStyle="Solid" ToolBarItemBorderWidth="1px" 
    ToolBarItemPressedBorderColor="51, 102, 153" ToolBarItemPressedBorderStyle="Solid" ToolBarItemPressedBorderWidth="1px" 
    ToolBarItemPressedHoverBackColor="153, 187, 226" >
    <LocalReport ReportPath="reports\Counts_Listings\EventListingByFields056.rdlc">
        <DataSources>
            <rsweb:ReportDataSource DataSourceId="EventListingByGroup_DataInstance" Name="dsAEMSReports_AEMSReports_056_EventListingByFields" />
        </DataSources>
    </LocalReport>
</rsweb:ReportViewer> 

In the .aspx.cs Page_Load routine, we have this code:

if (!IsPostBack)
{
    // Set hidden fields on the form for the Select parameters...  
    tbFromDate.Text = Request.Form["txtFromDate"].Trim();
    // ...clip...
    rvEventListingByGroup.Attributes.Add("style", "margin-bottom: 30px;");
    rvEventListingByGroup.Visible = true;

    string[] path = HttpContext.Current.Request.Url.AbsolutePath.Split('/');
    string reportPath = "";
    int length = path.Length;
    for (int i = 1; i < length - 1; i++)
    {
        if (path[i] == "Reports")
        {
            for (int j = i; j < length - 1; j++)
            {
                reportPath += path[j] + "/";
            }
        }
    }
    rvEventListingByGroup.LocalReport.ReportPath = reportPath + "EventListingByGroup056.rdlc";
    rvEventListingByGroup.LocalReport.Refresh();
}

Our report's .rdlc looks like this: Our report's .rdlc looks like this and the resulting output looks like this: the resulting output looks like this

I have verified using SQL Server Profiler that when the Report Viewer loads the page, it is calling SQL Server with the correct parameters to return all of the necessary data, but the data isn't rendering on the page. I know there are no footers, nor are there any settings to manage paging, so it will always read "1 of 1" until I fix that, but what I'm expecting is a long page of (in our test case) 150 rows worth of raw data.

Can anyone offer suggestions as to what I could have missed in this?

Thank you so much in advance. We thought this would be a simple change, but since our Report Writer (staff member) left, we're on the hook for getting these changes made, in short order, without the requisite skills to back it up...


Solution

  • I found my answer, thanks to this link from social.msdn. I added SizeToReportContent="true" to my ReportViewer declaration in the .aspx file, and the output now rendered correctly in the Previewer. Without it, no content rendered, afterwards, it was all there!