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

Binding Report List to ObjectDataSource List Property

2 Answers 1107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Axial
Top achievements
Rank 1
Axial asked on 05 Nov 2015, 10:50 PM

I'm trying to figure out how to bind a List to a List<T> property of my main data source and I'm having trouble.

 I have a report that binds like this:

                var report = new TQuoteReport
                {
                    DataSource = new ObjectDataSource
                    {
                        DataSource = quote // Quote is my object
                    }
                };

                var reportProcessor = new ReportProcessor();

                var reportSource = new InstanceReportSource()
                {
                    ReportDocument = report
                };

                var renderingResult = reportProcessor.RenderReport("PDF", reportSource, null);

                return renderingResult.DocumentBytes;

 And the Quote looks like this:

     public class Quote
    {

        public int Id { get; set; }
        public DateTime Created { get; set; }

        ...

        public List<LineItem> LineItems { get; set; }

    }

 where LineItem is just a basic object like this:

    public class LineItem

    {

        public int Id { get; set; }

        ...

    }

 

The main report binding fields work great with [= Fields.Id]

However, I can't figure out how to bind the LineItem List to a List report object. In the designer it will only let me bind the datasource with the ObjectDataSource that is set to Quote. It won't let me choose the LineItem list. I feel like I'm missing something here. 

 What am I not doing right? I would rather keep it all in one report and not do a subreport if I don't have to.

 Thanks!

        public int Id { get; set; }

     public class Quote
    {

        public int Id { get; set; }
        public DateTime Created { get; set; }

        ...

        public List<LineItem> LineItems { get; set; }

    }

     public class Quote
    {

        public int Id { get; set; }
        public DateTime Created { get; set; }

        ...

        public List<LineItem> LineItems { get; set; }

    }

2 Answers, 1 is accepted

Sort by
0
Accepted
Axial
Top achievements
Rank 1
answered on 05 Nov 2015, 11:38 PM

Nevermind. I figured out how to bind it with a binding called DataSource and the expression [=ReportItem.DataObject.LineItems] 

 I had missed the DataSource item in the binding property.

0
Stef
Telerik team
answered on 06 Nov 2015, 02:46 PM
Hello Austin,

Thank you for this update. I am glad to hear the issue is resolved.

For any one interested in the solution, please check How to use the ReportItem.DataObject property in expressions and How to Databind to Collection Properties.

Regards,
Stef
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
Axial
Top achievements
Rank 1
Answers by
Axial
Top achievements
Rank 1
Stef
Telerik team
Share this question
or