0
votes

i have web application in which i am using crystal reports.In main crystal report i want to display two sub reports but when i try to that, it displays data of main-report but other two sub report data is not dispalyed.i tried following code but doesn't work.

ReportDocument rptDoc = new ReportDocument();
DataTable dt1, dt2;
dt1 = new SalesMasterRepository().GetSalesHeaderData(Salesid);

 dt2 = new SalesMasterRepository().GetSalesFooterData(Salesid);

 DataTable dtproductview=getProductViewDetails();
  rptDoc.Load(Server.MapPath("../Reports/SalesProductReport.rpt"));
            rptDoc.SetDataSource(dtproductview);
            rptDoc.Subreports[0].SetDataSource(dt1);
            rptDoc.Subreports[1].SetDataSource(dt2);
 CrystalReportViewer1.ReportSource = rptDoc;

that's it i don't get any error but data also not displayed.

1

1 Answers

1
votes

i have got the solution

SalesProductReport rptDoc = new SalesProductReport(); //Main report

    DataTable dt1, dt2;
    dt1 = new SalesMasterRepository().GetSalesHeaderData(Salesid);

     dt2 = new SalesMasterRepository().GetSalesFooterData(Salesid);

     DataTable dtproductview=getProductViewDetails();
    salesrpt.Subreports["Sales_header1.rpt"].SetDataSource(dt1);//datasource for subreport

        rptDoc .SetDataSource(dtproductview);//Mainreport datasourcce
       rptDoc .Subreports["SalesFooter.rpt"].SetDataSource(dt2);//datasource for subreport

    CrystalReportViewer1.ReportSource = rptDoc ;