Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding object data source with nested list objects in RDLC

Tags:

c#

rdlc

I know we can bind object data source to RDLC. I am trying to bind an object like as follows:

public class ContactReportData
{
   public string ContactReportHeading{get;set;}
   public string ContactReportSubHeading{get;set;}
   public List<Contact> ContactDetails{get;set;}
}

public class Contact    {
   public string ContactName{get;set;}
   public string ContactDesignation{get;set;}
}

While Setting to RDLC, it will find only one dataset at time, say ContactReportData (without the list of contact) OR Contact. I guess that is because the report needs it to be in that way.

What I want is to have the data shown in report as : ContactReportHeading ContactReportSubHeading tabular form of Contacts in - Contact Name, Designation.

I could have given this as the details of report data as static and only bind the contacts list, but what I have is list of contact reports where I a facing the issue.

like image 765
Chinjoo Avatar asked Jan 17 '12 13:01

Chinjoo


1 Answers

I solved this by making my object retun as a flat list of anonymous object having all the properties of contact as well as the additional properties of parent object. Then in the RDLC report, added a table and bound the properties of contact object and then added a groups to the parent properties.

Summary is for making such layout you need to add grouping.

like image 152
Chinjoo Avatar answered Sep 20 '22 17:09

Chinjoo