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

ObjectDataSource Outside the report?

1 Answer 189 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Aubrey Ivan
Top achievements
Rank 1
Aubrey Ivan asked on 31 Oct 2019, 07:58 AM

Hi Admin,

Is it possible to pass the object datasource outside a report and then inside the constructor of the report there is a parameters for that datasource which will be used by the report? Is that possible using Type Resource Report? I am using asp .net MVC

also is it possible to pass an object or data table inside the TypeReportSource parameter?

something like this

 

        public ActionResult Index()
        {

            var organisation = _organisationLogic.GetOrganisation();

            var typeReportSource = new TypeReportSource()
            {
                TypeName = typeof(OrganisationReportSample).AssemblyQualifiedName
            };

            var sample = new Sample();
            var samples = new DataTable();
            samples = sample.GetReportData();

            typeReportSource.Parameters.Add(new Parameter("samples", samples));
            return View(typeReportSource);
        }

 

I am passing a data table inside the Report constructor and will use it like this..

 

        public OrganisationReportSample(DataTable samples)
        {
            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //      
            this.DataSource = samples;
        }

 

 

is this possible or not?

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 04 Nov 2019, 05:11 PM

Hello Aubrey Ivan,

If you use TypeReportSource the report will be instantiated by the Reporting engine with System.Reflection, and it will use its parameterless constructor. Hence, if you want to use a Report that accepts a parameter in the constructor, you will need to instantiate it manually and return it wrapped in an InstanceReportSource. This should happen in a Custom Report Resolver.

Please, check my reply to the Forum post you opened on a similar matter for more details - InstanceReportSource Not Working, Viewers says No Report

Regards,
Todor
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Aubrey Ivan
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or