Articles in this section
Category / Section

How to create RDLC report using Business Object Data Source?

4 mins read

The following shows the procedure to create RDLC report using Microsoft Visual C#.

  1. Open Microsoft Visual studio, in New Project dialog box, choose Visual C#, and then choose the WPF Application template and give project name, and click OK.
    Note:

    Choose the New Project template based on your development platform. It can be a WPF, ASP.NET and Windows Forms.

  1. From the Project menu, select Add New Item, choose Class, name as SalesPersons and click Add.
  2. Replace the default code for SalesPersons.cs with the following code:

            C#

#region SalesPersons
 
public class SalesPersons
{
    public string Name { get; set; }
    public double QS1 { get; set; }
    public double QS2 { get; set; }
    public double QS3 { get; set; }
    public double QS4 { get; set; }
    public double Total { get; set; }
    public int Year { get; set; }
 
    public static IList GetTopSalesPerson()
    {
        List<SalesPersons> SalesPersonCollection = new List<SalesPersons>();
        SalesPersons salesPerson = null;
        salesPerson = new SalesPersons()
        {
            Name = "Carol Elliott",
            QS3 = 656287.9884,
            QS4 = 1006810.7219,
            Total = 1663098.7103,
            Year = 2001
        };
        SalesPersonCollection.Add(salesPerson);
        salesPerson = new SalesPersons()
        {
            Name = "Linda Ecoffey",
            QS3 = 547589.0181,
            QS4 = 951811.3768,
            Total = 1499400.3949,
            Year = 2002
        };
        SalesPersonCollection.Add(salesPerson);
        salesPerson = new SalesPersons()
        {
            Name = "Shelley Dyck",
            QS3 = 551800.5660,
            QS4 = 823059.5628,
            Total = 1374860.1288,
            Year = 2001
        };
        SalesPersonCollection.Add(salesPerson);
 
        return SalesPersonCollection;
    }
}
 
#endregion
 
#region Stores
 
public class Stores
{
    public string Name { get; set; }
    public double QS1 { get; set; }
    public double QS2 { get; set; }
    public double QS3 { get; set; }
    public double QS4 { get; set; }
    public double Total { get; set; }
    public int year { get; set; }
 
    public static IList GetTopStores()
    {
        List<Stores> StoreCollection = new List<Stores>();
        Stores store = null;
        store = new Stores()
        {
            Name = "Bicycle Company",
            QS3 = 656287.9884,
            QS4 = 1006810.7219,
            Total = 1663098.7103,
            year = 2001
        };
        StoreCollection.Add(store);
        store = new Stores()
        {
            Name = "Activity Center",
            QS3 = 656287.9884,
            QS4 = 1006810.7219,
            Total = 1663098.7103,
            year = 2002
        };
        StoreCollection.Add(store);
        store = new Stores()
        {
            Name = "Bike Shop",
            QS3 = 656287.9884,
            QS4 = 1006810.7219,
            Total = 1663098.7103,
            year = 2001
        };
        StoreCollection.Add(store);
 
        return StoreCollection;
    }
}
 
#endregion
 
#region Products:
 
public class Products
{
    public string Name { get; set; }
    public double QS1 { get; set; }
    public double QS2 { get; set; }
    public double QS3 { get; set; }
    public double QS4 { get; set; }
    public double Total { get; set; }
    public int Year { get; set; }
 
    public static IList GetTopProducts()
    {
        List<Products> ProductCollection = new List<Products>();
        Products product = null;
        product = new Products()
        {
            Name = "AWC Logo Cap",
            QS3 = 2104165.3554,
            QS4 = 3308323.5938,
            Total = 5412488.9492,
            Year = 2001
        };
        ProductCollection.Add(product);
        product = new Products()
        {
            Name = "S-100 Helmet, B",
            QS3 = 1988382.4844,
            QS4 = 3279281.6611,
            Total = 5267664.1455,
            Year = 2001
        };
        ProductCollection.Add(product);
        product = new Products()
        {
            Name = "L-Sleeve Jrsey",
            QS3 = 1974839.7878,
            QS4 = 3282139.2608,
            Total = 5256979.0486,
            Year = 2001
        };
        ProductCollection.Add(product);
 
        return ProductCollection;
    }
}
 
#endregion
  1. From the Project menu, select Build Solution. This creates an assembly for the object, which you will later use as a data source for the report.
  2. Right click on the project and go to Add New Item dialog, select Report Wizard and name as Sales Dashboard.rdlc for the report and click Add. This shows the Report Wizard dialog.
  3. In the Choose a Data Source Type page, select Object and click Next.
  4. In the Select the Data Objects page, expand the class hierarchy until you see Products in the list. Select Products and click Finish.

Select Products in Data Source Configuration Wizard

  1. In the Dataset Properties page, check the Available datasets box, verify that Product is selected  and click Next.
  2. In the Arrange Fields page drag Name, QS1, QS2, QS3, QS4 from available fields to the Values box. Click Next twice, then click Finish. This creates the .rdlc file and opens it in designer page and displays the tablix created.
  3. Save the .rdlc file.

 

Also the RDLC report can be created using Syncfusion ReportDesigner, refer to the online documentation from the below location.

https://help.syncfusion.com/wpf/reportdesigner/create-rdlc-reports-through-wizard

 

The created reports can be used in the Syncfusion reporting controls.


Conclusion

I hope you enjoyed learning about how to create RDLC report using Business Object Data Source in WPF.

You can refer to our WPF Report Viewer page to know about its other groundbreaking feature representations and how to quickly get started for configuration specifications. You can also explore our WPF demo to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied