Search results
Suggest a FeaturePDF

Render RDLC report

The data binding support, allows you to view RDLC reports that exist on the custom business object data collection. The following steps demonstrates how to render a RDLC report with custom business object data collection.

Add the RDLC report product-list.rdlc from Bold Reports installation location to your application Resources folder. For more information, see Samples and demos.

  • Assign the processingMode property to ProcessingMode.Local.
  • To load report as a stream, create a report stream using the Stream class and assign the report stream to the LoadReport() method.
  • Bind the business object data values collection by adding new item to the DataSources as in the following code snippet.
Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly;
Stream reportStream = assembly.GetManifestResourceStream("ReportViewer.Resources.product-list.rdlc");
this.ReportViewer.ProcessingMode = BoldReports.UI.Xaml.ProcessingMode.Local;
this.ReportViewer.LoadReport(reportStream);
this.ReportViewer.DataSources.Clear();
this.ReportViewer.DataSources.Add(new BoldReports.UI.Xaml.ReportDataSource { Name = "list", Value = ProductList.GetData() });
this.ReportViewer.RefreshReport();

......

public class ProductList
{
    public string ProductName { get; set; }
    public string OrderId { get; set; }
    public double Price { get; set; }
    public string Category { get; set; }
    public string Ingredients { get; set; }
    public string ProductImage { get; set; }

    public static IList GetData()
    {
        List<ProductList> datas = new List<ProductList>();
        ProductList data = null;
        data = new ProductList()
        {
            ProductName = "Baked Chicken and Cheese",
            OrderId = "323B60",
            Price = 55,
            Category = "Non-Veg",
            Ingredients = "grilled chicken, corn and olives.",
            ProductImage = ""
        };
        datas.Add(data);
        data = new ProductList()
        {
            ProductName = "Chicken Delite",
            OrderId = "323B61",
            Price = 100,
            Category = "Non-Veg",
            Ingredients = "cheese, chicken chunks, onions & pineapple chunks.",
            ProductImage = ""
        };
        datas.Add(data);
        data = new ProductList()
        {
            ProductName = "Chicken Tikka",
            OrderId = "323B62",
            Price = 64,
            Category = "Non-Veg",
            Ingredients = "onions, grilled chicken, chicken salami & tomatoes.",
            ProductImage = ""
        };
        datas.Add(data);

        return datas;
    }
}