Sample on ReportViewer controls with Object data sources containing nested objects


I made a couple of changes in the object data source sample on www.gotreportviewer.com to illustrate the use of nested objects in report fields


I have added a ProductSales sub-class to the Product class. ProductSales has two fields: Quantity and Price.


In the report - you can reference them via:


Fields!Sales.Value.Quantity and Fields!Sales.Value.Price


You can similarly use multiple levels of object nesting, for example:


Fields!Sales.Value.Customer.Name


See attachment for details.


.

NestedObjectDatasources.zip

Comments (4)

  1. c60 says:

    Question: Utilizing an object graph as the given data source is there anyway to allow the Lists / Matrix / and or Table, within the given report, to utilize / bind to child collections vs. having to use a sub-report just to contain said table / and or matrix…?  And if so, then within a given List having a contained List utilizing yet another contained collection of an item within the parent collection…

    Cheers,

    Robert

  2. BoydFerris@gmail.com says:

    You may need to make sure that your report is executing within your AppDomain in order for the report to access the fields of the nested object.  The following code snippet shows how to do this:

    {reportObjectViewerObject}.LocalReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence);

  3. rosjon says:

    If you strong name your assemblies it wont work if you to use nested objects. Only thing that will show in your table is #Error.

  4. 刘乐光 says:

    前两篇Blog提到的问题得到了Reporting Service项目组Tudor的答复: 1.gotreportview上两个例子的疑问。 LocalReport.DataSources takes a

Skip to main content