Cos Callis
Cos Callis

Reputation: 5084

.RDLC Report 2008 (in VS 2010) ReportViewer appears with no report or data

Working with .RDLC 2005 in VS 2008 this technique worked very well, now in .RDLC 2008 as implemented in VS 2010 I get a blank (or no?) report.

I have made a couple of changes to accommodate .RDLC 2008 and at this time I am getting no exceptions. The present (not desired) output looks like: enter image description here

I have a custom ReportController class that has a public method to ShowReport (also one to manage the exporting of reports, but that is not (yet) in play.)

From the asp.net page I invoke the controller in the property set (of Type DataSet, invoked by the page controller) like: (ReportController implements IDisposable)

try
{
    using (var reportController = new ReportController(true))
    {
         _ReportViewer = reportController.ShowReport("DemonstrationList", value, phReportHolder);

         if (_ReportViewer != null)
         {
             _ReportViewer.ShowRefreshButton = false;
             _ReportViewer.ShowPrintButton = false;
             _ReportViewer.Width = Unit.Pixel(700);// Unit.Percentage(99);
             _ReportViewer.Height = Unit.Pixel(700);// Unit.Percentage(90);
         }
    }

    lblRecordCount.InnerText = value.Tables[0].Rows.Count.ToString();
}
catch (Exception ex)
{
    phReportHolder.InnerHtml = string.Format("There was an error attempting to process this report <br/><br/><div style='color:White;'>{0}</div>", ex.Message);
}

and the ShowReport method is:

public ReportViewer ShowReport(string ReportName, DataSet ds, HtmlContainerControl ReportContainer)
{
    ReportContainer.Controls.Clear();
    ReportViewer reportViewer = BuildReport(ReportName, ds);
    ReportContainer.Controls.Add(reportViewer);
    return reportViewer;
}

This allows me to tell the controller to put any 'valid' report into any htmlcontainercontrol using any provided dataset.

BuildReport takes the data and the report name and builds the report as:

private ReportViewer BuildReport(string ReportName, DataSet ds)
{
      try
      {
         _activeDS = ds;
         string ReportFileName = ResolveRDLCName(ReportName);
             // ResolveRDLCName is used along with path strings 
             // initialized from configuration settings in the 
             // constructor to make this portable. 
         var viewer = new ReportViewer();
         viewer.ProcessingMode = ProcessingMode.Local;
         viewer.LocalReport.ReportPath = ReportFileName;
         viewer.LocalReport.DisplayName = ReportName;
         viewer.LocalReport.EnableHyperlinks = true;
         AssignReportData(ds, viewer.LocalReport);

        return viewer;
      }
      //...Exception handlers below are not invoked at this time

And 'AssignReportData' attaches the data to the report.

private static void AssignReportData(DataSet ds,  LocalReport Report)
{
         var listOfDatasources = Report.GetDataSourceNames();

         foreach (string dsn in listOfDatasources)
         {
            ReportDataSource rds = new ReportDataSource(dsn,ds.Tables[dsn]);
            Report.DataSources.Add(rds);
         }
}

Development techniques ensure that dataTable/dataSource names stay in agreement (and if they were not I would get a specific exception, which I do not.)

Upvotes: 1

Views: 2647

Answers (2)

khelmar
khelmar

Reputation: 101

I was having a similar problem which this blog post answered. Short answer is I needed to install the report viewer redistributable, and add the handler.

Upvotes: 2

oleschri
oleschri

Reputation: 2012

It seems like the report content gets rendered but is simply not visible.

Try to look at the generated HTML (DOM) with

  • Chrome: right-click on the report area, "Inspect Element" to explore the DOM
  • Internet Explorer: install the IE Developer Toolbar to explore the DOM

Maybe some CSS that has worked in the past now hides your report area.

Upvotes: 1

Related Questions