Reputation: 26812
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:
<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>
<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>
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
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
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