1
我很難在我的應用程序中使用reportviewer顯示子報表。它在本地調試時可以很好地工作。但是當我將它上傳到服務器時,子報告是空白的。當RDLC移動到服務器時丟失子報表
我相信SubreportProcessing事件不會觸發,因爲我沒有看到從SQL Server Profiler觸發存儲過程。這是我正在使用的代碼。
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;
}
}
您是否找到了解決方案呢? – Cyberdrew 2011-02-22 21:47:00