how to render the rdlc main report with multiple datasources from code behind in C#? RRS feed

  • Question

  • User1466552491 posted

    I am generating the pdf file out this code using 2 datatables of dataset, but, the data in pdf appearing from ds.Tables[0] only , not of ds.Tables[1].my code is as below . Kindly suggest solution...

    ReportViewer viewer = new ReportViewer();
    viewer.ProcessingMode = ProcessingMode.Local;
    viewer.LocalReport.ReportEmbeddedResource = @"D:\Projects\NIKHIL\NIKHIL\Report3.rdlc; viewer.LocalReport.ReportPath = @"D:\Projects\NIKHIL\NIKHIL\Report3.rdlc; viewer.LocalReport.DataSources.Clear();
    viewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", ds.Tables[0])); viewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", ds.Tables[1])); viewer.LocalReport.Refresh();
    byteViewer = viewer.LocalReport.Render(reportType, deviceInfo, out mimeType, out encoding, out extension, out streamIds, out warnings);
    return byteViewer;

    Sunday, January 6, 2013 3:51 AM

All replies

  • User-1528094326 posted

    It depends on where those data sources are used. If it's a single stand alone report and nothing fancy, then the way you are doing it is fine. If you have drill down reports, or sub reports in there, then you'll need to subscribe to those events using the reportviewer, and supply the datasource at that point in order for it to render properly.

    Tuesday, June 18, 2013 7:47 PM