none
How to create "form letter" type reports (one row per page)? RRS feed

  • Question

  • Hi, I'm new to reporting and can't figure out how to create one page per row of data using business objects as datasource. Even though I set a list as the datasource, only the first row/page shows up.

    Here's some code to show what I've done:

    The business objects

    using System.Collections.Generic;
    
    namespace Reporting
    {
        public class Order
        {
            public int OrderID { get; set; }
            public string OrderName { get; set; }
            public List<Orderline> Orderlines { get; set; }
        }
    
        public class Orderline
        {
            public int OrderlineID { get; set; }
            public int OrderID { get; set; }
            public string OrderlineName { get; set; }
        }
    }
    
    

    The Winform code-behind

    private void Form1_Load(object sender, EventArgs e)
            {
                List<Order> orders = new List<Order>();
                orders.Add(
                    new Order
                    {
                        OrderID = 1,
                        OrderName = "Order 1",
                        Orderlines = new List<Orderline> 
                        { 
                            new Orderline { OrderlineID = 1, OrderID = 1, OrderlineName = "Orderline 1"},
                            new Orderline { OrderlineID = 2, OrderID = 1, OrderlineName = "Orderline 2"},
                            new Orderline { OrderlineID = 3, OrderID = 1, OrderlineName = "Orderline 3"},
                        }
                    });
                orders.Add(
                    new Order
                    {
                        OrderID = 2,
                        OrderName = "Order 2",
                        Orderlines = new List<Orderline> 
                        { 
                            new Orderline { OrderlineID = 4, OrderID = 2, OrderlineName = "Orderline 4"},
                            new Orderline { OrderlineID = 5, OrderID = 2, OrderlineName = "Orderline 5"},
                        }
                    });
    
                reportViewer1.ProcessingMode = ProcessingMode.Local;
                reportViewer1.LocalReport.ReportEmbeddedResource = "Reporting.OrdersReport.rdlc";
                ReportDataSource ds = new ReportDataSource("reportDataSet", orders.ToList());
                reportViewer1.LocalReport.DataSources.Add(ds);
    
                this.reportViewer1.RefreshReport();
            }
    

    If I make the report using the wizard and select Objects as datasource type and then Order as the source, I get a Tablix showing both Orders in the list of objects (without children). Unfortunately, that's not what I need. When I remove the Tablix and drag fields onto the report surface I only get a single page in the report showing the first row. Why is there no second page with row 2?

    TIA

    Dennis

    Friday, September 23, 2011 4:24 AM