Click here to Skip to main content
16,020,459 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using subreport for my Crystal report. I am using following coding for set subreports. Main report has come but the subreport will not display. Please help me

ReportDocument rptdoc = new ReportDocument();
    rptdoc.Load(Server.MapPath("CUSTOMERWISEREPORT.rpt"));
    //rptdoc.OpenSubreport("SALESTRANSACTION").SetDataSource(ds2.Tables[0]);
    //rptdoc.OpenSubreport("RECEIPTTRANSACTION").SetDataSource(ds3.Tables[0]);

    rptdoc.Subreports[0].SetDataSource(ds2.Tables[0]);
    rptdoc.Subreports[1].SetDataSource(ds3.Tables[0]);
    rptdoc.SetDataSource(ds.Tables[0]);
Posted

try this ,My working code...

C#
Common.Common obj = new Common.Common();
    ReportDocument RptDocument = new ReportDocument();
    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet dsFiiReport123 = obj.GetData("uspGetHeader", new object[] { });
        DataSet dsFiiReport = obj.GetData("uspReportData", new object[] { });

        if (dsFiiReport.Tables[0].Rows.Count > 0)
        {
            CrystalReportViewer1.DisplayGroupTree = false;
            dsFiiReport.Tables[0].TableName = "uspReportData";

            RptDocument.Load(Server.MapPath("~/Report/crvData.rpt"));
            RptDocument.SetDataSource(dsFiiReport);
            RptDocument.Subreports[0].SetDataSource(dsFiiReport123.Tables[0]);
            CrystalReportViewer1.ReportSource = RptDocument;
            CrystalReportViewer1.DataBind();
            CrystalReportViewer1.Visible = true;
        }
        else
        {
            CrystalReportViewer1.Visible = false;
            Response.Write("<script>alert('No Recordes Found')</script>");
       }
    }
 
Share this answer
 
v2
use like this
C#
rptdoc.SetDataSource(ds.Tables[0]);
rptdoc.Subreports[0].SetDataSource(ds2.Tables[0]);
rptdoc.Subreports[1].SetDataSource(ds3.Tables[0]);
 
Share this answer
 
v2
Comments
devausha 16-Apr-12 1:38am    
I have already try this. But the subreport didn't come
pritesh.cs@gmail.com 4-Jun-12 5:14am    
It's works for me....Excellent... Thanks...
marjuke 1-Jul-21 2:23am    
sir i have got error when i create subreport on ds3.tables[0]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900