Reporting IReportSourceResolver

1 Answer 72 Views
Report Parameters Report Viewer - ASP.NET Report Viewer - HTML5
Tomas
Top achievements
Rank 1
Tomas asked on 31 Aug 2023, 01:14 PM

Hello,

I implement reports and use IReportSourceResolver. When report viewer asks for a report, the method is called 3x. I need to load data into the report using objectDataSource. But the problem is that the parameters from currentParameterValues are loaded only in the first call (OperationOrigin.ResolveReportParameters). In the other two, the variable is already empty. Can you please help me? 

Thank you

public ReportSource Resolve(string uri, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
        {
            var reportPackager = new ReportPackager();
            var report = Construct.CommonManager.Report.GetModelFromUri(uri);

            if (report == null)
            {
                throw new FileNotFoundException();
            }

            MemoryStream stream = new(report.Data);
            Telerik.Reporting.Report report1 = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(stream);
         
            var instanceReportSource = new InstanceReportSource
            {
                ReportDocument = report1
            };

            if (operationOrigin == OperationOrigin.ResolveReportParameters)
            {

            }
            else if (operationOrigin == OperationOrigin.CreateReportInstance)
            {

            }
            else if (operationOrigin == OperationOrigin.GenerateReportDocument)
            {

            }

            return instanceReportSource;
        }

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 04 Sep 2023, 08:58 AM

Hi Tomas,

Indeed, the IReportSourceResolver.Resolve method is called three times when a report is being initially loaded by the report viewer. This and the currentParameterValues dictionary being populated only in the ResolveReportParameters call is expected behavior.

If you need to perform certain operations based on those values, you would need to save them during this call. For example, a static dictionary that you may later access in the other 2 calls.

For more details on this method's behavior, I suggest reading the Using Custom ReportSource Resolver and Custom ReportDocument Resolver - Telerik Reporting article.

Please let me know if you have any additional questions.

Regards,
Dimitar
Progress Telerik

Stay tuned by visiting our roadmap and feedback portal pages, enjoy a smooth take-off with our Getting Started resources, or visit the free self-paced technical training at https://learn.telerik.com/.
Tags
Report Parameters Report Viewer - ASP.NET Report Viewer - HTML5
Asked by
Tomas
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or