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;
}
}