ReportViewer 2010 not refreshing on async postback
Ok I've have been searching and trying different ideas for a good six hours and I have not found a solution.
I'm using Visual Studio 2010, C#, ASP.Net 4.0 and ReportViewer 10.
I have a javascript function that makes a async call to refresh report parameters with new values and then reloads the report. Everything executes as expected but the report does not render the new data.
If I do a normal postback from a button then it works, but as soon as it is a async postback it doesn't. I have read something that the rendering might be to late in the page life-cycle etc. but this has left me nowhere. Here is the code I use to set the parameters.
Code Behind:
//Tried with and without this line and it makes no differed
ReportViewer1.Reset();
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
List<ReportParameter> rParams = new List<ReportParameter>();
rParams.Add(new ReportParameter("UserID", SelectedUserID.ToString(), 开发者_如何学Cfalse));
rParams.Add(new ReportParameter("PayrollSalesMonthID", "13", false));
ReportViewer1.ServerReport.ReportServerUrl = new Uri("...");
ReportViewer1.ServerReport.ReportPath = "...";
ReportViewer1.ServerReport.SetParameters(rParams);
//Tried with and without this line and it makes no differed
ReportViewer1.ServerReport.Refresh();
Markup:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" BorderStyle="None" Width="100%" Height="98%" SizeToReportContent="true" AsyncRendering="true" />
</rsweb:ReportViewer>
UPDATE
I have both a ASP Script Manager and a EXT.Net Resource Manager on my page as below and this is causing the error. As soon as I remove the Resource Manager it works fine but I do need it for other functionality on this page. Also putting the report in an iFrame is out the of the question.
<ext:ResourceManager ID="ResourceManager1" runat="server" Locale="en-GB" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Any ideas on how to get these two Managers to play along nicely?
Have you set scriptmanager.EnablePartialRendering
flag to true
?
Try to put the ReportViewer inside an UpdatePanel, or call ReportViewer1.Update method (i haven't try this), Update method is an extension methond from Ext.Net to all Controls that refresh the control state in the client.
I hope it works for you. Regards, Paúl Somarriba
精彩评论