开发者

Missing Subreports when RDLC is moved to server

I'm having a hard time getting a sub report to show up in my application using reportviewer. It works perfectly when debugging it locally. But when I upload it to the server, the sub reports are blank.

I've believe that SubreportProcessing event is not firing since I don't see the stored procedures getting fired from SQL Server Profiler. Here is my code that I'm using.

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 = r开发者_运维知识库eport.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;
        }


    }


I seem to have the same issue. I believe that the problem is that when deployed reportPath contains the full path for the report, but when you are debugging locally it passes only the report name.

Is it possible that your SubreportProcessing event is indeed firing but in your switch statement non of the cases match the full path contained in the reportPath parameter.

I don't know how to resolve that but I think that might be the root cause.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜