w00
w00

Reputation: 26812

ReportViewer keeps refreshing

I have a very weird situation. I'm using a ReportViewer control in ASP.NET to show a report in my aspx page. This works fine when i build my web site with VS2008. But it goes wrong when i add a Report Viewer control to a page in VS2010...

The problem i have with the ReportViewer in VS2010 is that it constantly keeps refreshing my report. When i view the network traffic that i send from that page i can clearly see the ReportViewer is constantly sending a new request to get the report. I have no clue why it is behaving like this, and only in VS2010...

But this ONLY happends when i try to add a parameter to my report.

This is what my code looks like:

VS2008

<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
    Font-Size="8pt" Height="642px" ProcessingMode="Remote" Width="896px">
    <ServerReport ReportPath="http://server.com/Product/Dashboards/test.rdl" 
        ReportServerUrl="http://server.com/ReportServer" />
</rsweb:ReportViewer>

VS2010

<rsweb:ReportViewer ID="ReportViewer1" runat="server" 
ProcessingMode="Remote" Width="948px" Font-Names="Verdana" Font-Size="8pt" 
     WaitMessageFont-Names="Verdana" 
    WaitMessageFont-Size="14pt">
    <ServerReport ReportPath="http://server.com/Product/Dashboards/test.rdl" 
        ReportServerUrl="http://server.com/ReportServer" />
</rsweb:ReportViewer>

Code behind

For both VS2008 and VS2010 i have the following code in my Page_Load:

ReportParameter[] reportParameters = new ReportParameter[1];
reportParameters[0] = new ReportParameter("year", "2012", true);
ReportViewer1.ServerReport.SetParameters(reportParameters);
ReportViewer1.ServerReport.Refresh();

Why do i have problems with VS2010 when i add parameters, ie: Why does it keeps refreshing my report? And why is this working perfectly fine in VS2008?

Upvotes: 2

Views: 2591

Answers (2)

Kelsey
Kelsey

Reputation: 53

I know this is in an old one, but for those still looking I had this problem in ReportViewer2012 and solved it by checking for a post back in the code behind.

protected void Page_Load(object sender, EventArgs e)
{
  if (!IsPostBack)
   {
     // Your code behind code here
   }
}

This may also help: https://social.msdn.microsoft.com/Forums/en-US/deae558c-977f-484e-86ba-50cfd376c181/reportviewer-constantly-refreshing?forum=vsreportcontrols

Upvotes: 2

David McClelland
David McClelland

Reputation: 2756

This may be the problem you're encountering: Reports Never Stop Loading With VS 2010

Apparently you need a check for IsPostBack before calling SetParameters.

Upvotes: 1

Related Questions