Bind child object property with in rdlc (Report)

2019-02-24 08:31发布

问题:

I have a custom object say "objMain" in which i have few properties and also the property of object type (i.e. like a child object).

objMain has these properties: 1. Name [type: string] 2. Description [type: string] 3. StartDate [type: datetime] 4. ObjSubject [type: object] - this is of custom type

ObjAddress has these properties 1. SubjectID [type: int] 2. SubjectName [type: string]

I need to display Name, description, startdate and SubjectNames related to that name. It show the data in Name, description and startdate field but not is shown in the SubjectName field.

This is how i want to show:

Name | Description | StartDate | SubjectName

Amod Kumar ABCDEFG 19/08/2009 Physics Chemistry Maths

But result appears like this

Name | Description | StartDate | SubjectName

Amod Kumar ABCDEFG 19/08/2009

Can any body tell me how i do this. I also tried to show only the SubjectName in the table, it does not show any thing on the report. I am defining both datasource for report i.e. For objMain and ObjSubject.

回答1:

=Fields!ObjSubject.Value.SubjectName

That expression in a textbox on the report should give you the nested value.



回答2:

  1. Make a partial class of your base class
  2. Make a new property
  3. Define the logic in the getter and setter using your nested object property
  4. Then add it to the rdlc report like any other property of your base class