Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7529681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:43:27+00:00 2026-05-30T04:43:27+00:00

How do I create a report with a parent-child-grandchild relationship using POCOs / custom

  • 0

How do I create a report with a parent-child-grandchild relationship using POCOs / custom business objects?

public class Invoice
{
  public List<Account> Accounts { get; set; }
}

public class Account
{
  public List<LineItem> LineItems { get; set; }
}

public void GenerateReport()
{
    var localReport = new LocalReport();
    localReport.LoadReportDefinition(GetEmbeddedResource("Invoice.rdlc"));
    localReport.DataSources.Add(new ReportDataSource("InvoiceDataset", new List<Invoice> { invoices }));
}

Preferably using Table and List controls over Subreports. Reporting Services v10 with Local Processing (.rdlc files).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:43:28+00:00Added an answer on May 30, 2026 at 4:43 am

    Invoice.rdlc

    • Add a dataset named InvoiceDataset (from the Report Data tool window)
    • Add a List control (since the report must be bound to a list of Invoices even if the list will only ever contain one element)
    • Within the List control add Invoice-level fields like Customer Name
    • Within the List control add a Subreport control pointing to Account.rdlc with a name of “Account” and a parameter of InvoiceId

    Account.rdlc

    • Add a dataset named AccountDataset (from the Report Data tool window)
    • Add an InvoiceId parameter to match the parameter specified in Invoice.rdlc Subreport control
    • Add a List control
    • Within the List control add Account-level fields like Account Number
    • Within the List control add a subreport pointing to LineItem.rdlc with two parameters: InvoiceId and AccountId

    LineItem.rdlc

    • Add a dataset named LineItemDataset (from the Report Data tool window)
    • Add InvoiceId and AccountId parameters to match the parameters specified in Account.rdlc Subreport control
    • Add a List control
    • Within the List control add Line Item-level fields like Description, Quantity, Price

    To generate this report as a pdf:

    public byte[] GenerateInvoicePdf(Invoice invoice)
    {
        var localReport = new LocalReport();
    
        localReport.LoadReportDefinition(GetEmbeddedResource("Invoice.rdlc"));
        localReport.LoadSubreportDefinition("Account", GetEmbeddedResource("Account.rdlc"));
        localReport.LoadSubreportDefinition("LineItem", GetEmbeddedResource("LineItem.rdlc"));
        var datasource = new List<Invoice> {invoice};
        localReport.DataSources.Add(new ReportDataSource("InvoiceDataset", datasource));
        localReport.SubreportProcessing +=
            (o, args) =>
                {
                    if (args.ReportPath == "Account")
                    {
                        var invoiceId = long.Parse(args.Parameters["InvoiceId"].Values[0]);
                        var invoice = datasource.First(x => x.InvoiceId == invoiceId);
                        args.DataSources.Add(new ReportDataSource("AccountDataset", invoice.Accounts));
                    }
                    else if (args.ReportPath == "LineItem")
                    {
                        var invoiceId = long.Parse(args.Parameters["InvoiceId"].Values[0]);
                        var accountId = long.Parse(args.Parameters["AccountId"].Values[0]);
                        var invoice = datasource.First(x => x.InvoiceId == invoiceId);
                        var account = invoice.Accounts.First(x => x.AccountId == accountId);
                        args.DataSources.Add(new ReportDataSource("LineItemDataset", account.LineItems));
                    }
                };
        return localReport.Render("pdf");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a report, using either Crystal reports or RDLC, doesn't really
I am using SQL Server Reporting Services 2008 to create a report. A table
I am trying to create a report using a wcf service as a datasource.
I have a list of Child objects. I would like to be able to
My goal is to create report in WPF using dev express. I want to
I have two table cpuinfo and jobinfo. I want to create report using both
I have a custom class Person. Several Person objects have been created and added
CREATE TABLE #Report( Cell int, CellValue double) Error here DECLARE @Report TABLE ( Cell
When I create a report I can filter the results based on the logged
I want to create a report which aggregates the number of activities per customer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.