1

reportviewer を使用してアプリケーションにサブレポートを表示するのに苦労しています。ローカルでデバッグするときは完全に機能します。しかし、サーバーにアップロードすると、サブレポートが空白になります。

ストアド プロシージャが SQL Server Profiler から起動されていないため、SubreportProcessing イベントが起動していないと考えています。これが私が使用している私のコードです。

private void RunReport(string strFormat, int PlanID)
    {
        const string reportrdlc = "Reports\\Report_All_Sections.rdlc";
        LocalReport report = new LocalReport {ReportPath = Server.MapPath(reportrdlc)};
        report.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));
        report.DataSources.Clear();
        report.SubreportProcessing += SetSubDataSource;

        report.DataSources.Add(new ReportDataSource("DataSet_usp_GetSD", _wpt.Get_SD(PlanID).Copy()));

        report.Refresh();

        string mimeType;
        string encoding;
        string fileNameExtension;
        string[] streams;
        Warning[] warnings;

        byte[] pdfContent = report.Render(strFormat, null, out mimeType, out encoding,
                    out fileNameExtension, out streams, out warnings);

        System.IO.MemoryStream stream = new System.IO.MemoryStream(pdfContent);
        Response.ContentType = strFormat == "EXCEL" ? "application/vnd.ms-excel" : "application/pdf";

        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        Response.Close();
        stream.Close();

    }
    public void SetSubDataSource(object sender, SubreportProcessingEventArgs e)
    {
        int PlanID = 1;
        if (Request.QueryString["PlanID"] != null)
        {
            try
            {
                PlanID = Convert.ToInt32(Request.QueryString["PlanID"]);
            }
            catch (Exception Ex)
            {
                PlanID = 1;
            }
        }
        switch (e.ReportPath)
        {
            case "Report_All_Mentor":
                e.DataSources.Add(new ReportDataSource("DataSet_usp_GetMC", _wpt.Get_MC(PlanID).Copy()));
                break;
            case "Report_All_Intern":
                e.DataSources.Add(new ReportDataSource("DataSet_usp_GetEA", _wpt.Get_EA(PlanID).Copy()));
                break;
        }


    }
4

1 に答える 1

1

私は同じ問題を抱えているようです。問題は、デプロイされた reportPath にはレポートのフルパスが含まれているが、ローカルでデバッグしている場合はレポート名のみが渡されることだと思います。

SubreportProcessing イベントが実際に発生している可能性はありますが、switch ステートメントでは、reportPath パラメーターに含まれる完全なパスと一致するケースはありません。

それを解決する方法はわかりませんが、それが根本的な原因である可能性があると思います。

于 2014-02-17T11:22:43.923 に答える