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

Binding to IEnumerable<T>

1 Answer 198 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Greg St.Pierre
Top achievements
Rank 1
Greg St.Pierre asked on 20 Aug 2010, 05:22 PM
Hello all,

I have a windows form with a grid that displays items that can be selected by the user using check boxes. Each item has zero or more sub-items attached to them. I would like to let the user select the main items from the grid then have a report that displays all the sub-items that were attached to the selected items.

I have tried creating an ObjectDataSource using the Report Designer with no success. I have tried to manually data bind the report by programmatically setting the DataSource of the report to an IEnumerable<SubItem> that I have created. In this case I set the expressions for the textboxes in the report to [=Property1] where Property1 is a public property of the SubItem class. This gives me a row for each item in the IEnumerable<SubItem> list but instead of displaying the value of the properties it prints [=Property1].

Is it possible to use the reports in this way? If so how? Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 25 Aug 2010, 03:37 PM
Hi Greg St.Pierre,

You can bind to collection properties by using a separate Data Item (i.e. report, table, chart) e.g. you can use the Bindings property. This way you can bind declaratively the DataSource property of a data item to a given collection property from your business object and the data item will display all the collection items. To illustrate this approach better I have attached a small sample report to my post. If you need more information regarding this you can visit the following help topic from our online documentation which discusses property bindings via expressions more in-depth.

Kind regards,
Steve
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Greg St.Pierre
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or