This is a migrated thread and some comments may be shown as answers.

ReportViewer doesn't load after postback

3 Answers 271 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dana
Top achievements
Rank 1
Dana asked on 02 Dec 2009, 12:56 PM
Hello,

I am using Telerik Reporting Q2 2009 and facing the following strange issue: I have two report viewers on the page and a RadComboBox. The purpose of the combobox is to switch between the two viewers depending on the selection.

When loading the page, both viewers are displayed and refreshed correctly.
 
If I cause any postback in the page (I use the same code as in the load method) the viewer doesn't load any parameters for the report and therefore I am not able to use it in the same manner as I did after the page load.

Why does the viewer behave differently in the last case?

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 02 Dec 2009, 04:22 PM
Hello Dana,

Please elaborate on your last paragraph - namely are you doing with the Report Viewer in the postback event handler? Please note that if the viewers have reports set and you want to pass a value for their parameters, you should get the report object directly from the viewer like so, instead of creating a new report instance (common mistake):

Telerik.Reporting.Report report = (Telerik.Reporting.Report)this.ReportViewer1.Report;
report.ReportParameters["MyParam"].Value = <your_value>;
ReportViewer1.RefreshReport();

Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dana
Top achievements
Rank 1
answered on 03 Dec 2009, 08:46 AM

Hello

Thank you for your answer.

In the postback event handler I only want to hide/display a certain report. Example: in the page_load I load two reportviewers with the following code

if (!IsPostBack)  
            {  
                string connectionString = "some connection string";  
                MechanicReport.Report report = new MechanicReport.Report(connectionString);  
                reportViewerMechanic.Report = (IReportDocument)report;  
                reportViewerMechanic.RefreshReport();  
 
                WorkReportLib.WorkReport woreport = new WorkReport(connectionString);  
                reportViewerWO.Report = woreport;  
                reportViewerWO.RefreshReport();  
            } 

Then I have a radcombobox through which I want to hide/display a report based on the user's selection with the following code. 

I have tried all combiations (re-assigning a new report, only refreshing, oly displaying/hiding etc) but the reportviewer apparently is not able to show the report parameters/be usable as in the load event. This happens if I auseany other postback event in the page (the viewer loses it's initial state from load time, but is not able to recover even if i call RefreshReport() or reasign a new report to it)

 switch (e.Value)  
            {  
                case "Mechanic":  
 
                    //MechanicReport.Report report = new MechanicReport.Report(connectionString);  
 
                    reportViewerMechanic.Visible = true;  
                    reportViewerWO.Visible = false;  
 
                    //reportViewerMechanic.Report = report;  
                    reportViewerMechanic.RefreshReport();  
 
                    break;  
                case "WO":  
 
                    //WorkReportLib.WorkReport woreport = new WorkReport(connectionString);  
 
                    //reportViewerWO.Report = woreport;  
                    reportViewerWO.RefreshReport();  
                    
                    reportViewerMechanic.Visible = false; ;  
                    reportViewerWO.Visible = true; ;  
                    break;  
                default:  
                    break;  
 
            } 

0
Chavdar
Telerik team
answered on 08 Dec 2009, 04:31 PM
Hi Dana,

Try not to call the RefreshReport method when changing the visibility of the viewers. If the reports have parameters they will be always refreshed. The RefreshReport method should  be called only in some other special cases. If the problem still persists, please open a support ticket and send us a simple application that reproduces your case.


Best wishes,
Chavdar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Dana
Top achievements
Rank 1
Answers by
Steve
Telerik team
Dana
Top achievements
Rank 1
Chavdar
Telerik team
Share this question
or