加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 没有有效的报告来源 – 水晶报告

发布时间:2020-12-16 07:03:59 所属栏目:asp.Net 来源:网络整理
导读:我使用水晶报告创建了一份报告.我正在使用visual studio 2010.当我尝试转到另一个页面时会出现问题.当我尝试导航到第2页或最后一页时,错误屏幕上显示无可用的有效报告源.有谁知道我需要做什么?谢谢你的时间 解决方法 在Session中存储报告,然后在页面上发布
我使用水晶报告创建了一份报告.我正在使用visual studio 2010.当我尝试转到另一个页面时会出现问题.当我尝试导航到第2页或最后一页时,错误屏幕上显示无可用的有效报告源.有谁知道我需要做什么?谢谢你的时间

解决方法

在Session中存储报告,然后在页面上发布会话报告源

protected void Page_Load(object sender,EventArgs e)
{
       if (IsPostBack)
        {
            try
            {
                CrystalReportViewer1.ReportSource = (ReportDocument)Session["Report"];
                CrystalReportViewer1.RefreshReport();
                CrystalReportViewer1.DataBind();
            }
            catch (Exception ex)
            {

               // throw;
            } 
        }

    }
    protected void CrystalReportViewer1_PreRender(object sender,EventArgs e)
    {

    }
    protected void btnPrint_Click(object sender,EventArgs e)
    {
        ReportDocument rptDoc = new ReportDocument();
        rptDoc.Load(Server.MapPath("ReportsBalanceReportNewBalanceReport.rpt"));
        rptDoc.SetDataSource(ReportData());
        Session["Report"] = rptDoc;
        CrystalReportViewer1.ReportSource = rptDoc;
        CrystalReportViewer1.RefreshReport();
        CrystalReportViewer1.DataBind();
    }
    public DataTable ReportData()
    {
        string ClassName = ddlClass.SelectedValue;
        string Division = ddlDivison.SelectedValue;
        string Subject = ddlSubjects.SelectedValue;
        DataTable ReportData = objRpt.getReportData(ClassName,Division,Subject);
        return ReportData;
    }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读