How do you access Report Parameter Values of Subreport incase of Dynamic Data

Posted by: vasudev.potla on 13 May 2020, 8:01 am EST

  • Posted 13 May 2020, 8:01 am EST

    I would like filter data I set to subreport based on ReportParameter Values of Subreport. My question is how do I access subreport parameter values through LocateDataSourceEventArgs type.

                var data = await _someService.Get(id);
    
                string rptPath = HostingEnvironment.MapPath("/Reports/MainRpt.rdlx");
                GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport();
                rpt.Load(new System.IO.FileInfo(rptPath));
                //PesoCodeRpt rpt = new PesoCodeRpt();
                GrapeCity.ActiveReports.Document.PageDocument myDocument = new GrapeCity.ActiveReports.Document.PageDocument(rpt);
                Subreport subreport = (Subreport)((List)rpt.Report.Body.ReportItems["List1"]).ReportItems["Subreport1"];
                subreport.ReportName = Path.GetFullPath(HostingEnvironment.MapPath("/Reports/SubRpt.rdlx"));
                myDocument.LocateDataSource += new LocateDataSourceEventHandler((object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args) =>
                {
                    var x = args.Report.Name;
                    if (args.Report.Name.Contains("SubRpt.rdlx"))
                    {
                        var paramss = args.Report.ReportParameters;
                    }
                    else
                    {
                        args.Data = data;
                    }
                });
    

    thank you for your prompt response.

  • Posted 14 May 2020, 12:42 am EST - Updated 30 September 2022, 8:12 am EST

    Hello,

    You can’t access the subreport parameter in the locatedatasource. However, you can create parameter in the parent report and map the parameter with subreport parameter through parameters property of subreport control. Please refer to the attached image.

    Thanks,

    Mohit

  • Posted 14 May 2020, 12:55 am EST

    Yes, thats how did set the sub report parameters. And as we can set the data for subreport through locatedatasource, we thought we can access sub report parameters values and set filtered the data to subreport.

    I have a different question, I am setting the main report to a Object, example

    var MainObj = [
    {"Name": Vasu, Job:"Developer", PayHistory:[{x:1, y:2,z:[]},{x:1,y3,z:[]}]},
    {"Name": Ramesh, Job:"Manager", PayHistory:[{x:1, y:2,z:[]},{x:1,y3,z:[]}]},
    ]
    
    

    Is there a way to pass an Array of objects like PayHistory from the above example to subreport from main report?

  • Posted 19 May 2020, 10:14 pm EST

    Hello,

    I am very sorry for the delay!

    Yes, it is possible to pass the array of object to the subreport. Please refer to the attached project.

    Thanks,

    Mohit

    Project_ObjectDataSource.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels