How to display a child List inside of the DataSour

2019-09-17 17:27发布

问题:

I have created a static Generic List (List) and bind it to a Report Viewer's data source. In the Report Viewer designer, I am able to find the correct data source which is List and also able to drag and drop properties like ProductName, ProductNo from a single Product object onto the report.

However, this Product object itself contains another List (List). My question is how I can get the objects from this inner List and display them onto the report?

Any help would be much appreciated!

回答1:

2 ways:

  1. If the actual second list is related to the first list, that is you have some sort of join on a OneSideTable.ID = ManySideTable.ID. In that case your reports group would be by the OneSideTable.ID and the child records would be placed in the details section so that you get something to this effect:
Product: Ford
    -Focus
    -Mustang
    -Edge
    -Escape
    -Taurus    Product: GM
    -Accadia
    -Cobalt
    -HHR    ....
    ...

TWO. The other way to do it is you could have a second data source and drag and drop another table / list object onto the report. You would tell this object to take on the second datasource dsSecond. Then you can drag and drop your fields from this second dataset into this table / list of the report.

Very simple!



标签: report viewer