nitedmn
nitedmn

Reputation: 94

Rendering SSRS report, with no parameters, using ReportViewer control fails

I'm working with an ASP.Net page which displays reports from a remote SSRS server using the ReportViewer control. It was working without problems until we deployed a new report which doesn't require/accept any parameters. When rendering these reports, the first page of the report would render fine but when you switch to another page (using the controls from ReportViewer) you get an error saying, "One or more data sources is missing credentials".

enter image description here

This is how the ReportViewer is being configured...

this.Report.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
this.Report.ServerReport.ReportServerUrl = new Uri(App.Config.ReportServerPath);
this.Report.ServerReport.ReportPath = this.ReportPath;
this.SetRerportParameterValues(); // This does nothing since the report doesn't have any parameters
this.Report.AsyncRendering = false;

If I change the AsyncRendering to true, the error will be displayed when rendering the first page of the report.

When rendering a report, which doesn't have any parameters, is there something different I have to do with the parameters?

Upvotes: 0

Views: 1505

Answers (2)

nitedmn
nitedmn

Reputation: 94

I'm still not exactly sure why this is occurring but I did find the cause and was able to resolve it.

My ASPX page was inheriting from a custom page base (which inherited System.Web.UI.Page). The initialization of the base page was looping through all HTML controls on the page and attaching a simple handler to the change event. The event handler would simply add the control to a list when it's value was modified. This event handler is pretty simple and looks like this...

 private void HtmlCtrl_ServerChange(object sender, EventArgs e)
    {
        HtmlControl ctrl = sender as HtmlControl;
        if (ctrl != null)
        {
            this.changedControls.Add(ctrl);
        }
    }

For some reason, I'm still not sure why, this functionality messed up the ReportViewer control when you tried to navigate to the second page of a report with zero parameters. To resolve this I just added an additional property to my base page class which allows me to disable the change tracking functionality since it's not needed on this page anyway.

Upvotes: 0

Irf
Irf

Reputation: 4607

Better you remove

this.SetRerportParameterValues();

As this seems to do nothing.

And, are you sure there aren't any sub-reports in this very report ? If yes, you may need to check for its query/data source etc.

EDIT

There are some known issues with the reportviewer control. I personally take the reportviewer as only the basic viewer when designing the reports, as from User perspective reportViewer is not the best option, due to some issues.
So, in order to get the report data output to be shown to user, it is a better option to convert report to PDF on the fly from code behind, and show the PDF to the user.

Upvotes: 0

Related Questions