水晶报表显示到aspx页面中

1.在前台添加水晶报表显示控件。

<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />

 2.后台添加绑定代码。

protected void Page_Load(object sender, EventArgs e)
        {
            //创建报表文档  
            ReportDocument myReport = new ReportDocument();
            //取到报表文件物理路径  
            string reportPath = Server.MapPath("CrystalReport1.rpt");
            myReport.Load(reportPath);  
            //将创建的新的报表文档绑定  
            this.CrystalReportViewer1.ReportSource = myReport;
            this.CrystalReportViewer1.DataBind();  
        }
原文地址:https://www.cnblogs.com/Evan-Pei/p/3154303.html