Hola lista...como va?
Estoy teniendo un problema con un reporte que a su vez tiene un subreporte y
no le encuentro la vuelta.
Al ejecutar el reporte, me da este error:
"Data retrieval failed for the subreport, 'mails', located at:"
Alguno sabe si hay alguna config. especial ? Googleando siempre encuentro
ejemplos para winforms y nunca para web.
Mi codigo es este:
private void SubReporteMails(object sender, SubreportProcessingEventArgs e)
{
try
{
LocalReport lr = (LocalReport)sender;
e.DataSources.Add(new ReportDataSource("dtEmpresasMails",
lr.DataSources["dtEmpresasMails"].Value ));
}
finally
{
}
}
private void RenderReport(string ReportPath, object empresas, object
mails)
{
FileStream report = null;
FileStream subreport = null;
var localReport = new LocalReport { ReportPath = ReportPath };
try
{
report = new
FileStream(Server.MapPath("~/Views/Consultas/Test.rdlc"), FileMode.Open,
FileAccess.Read);
localReport.LoadReportDefinition(report);
subreport = new
FileStream(Server.MapPath("~/Views/Consultas/EmpresaMails.rdlc"),
FileMode.Open, FileAccess.Read);
localReport.LoadSubreportDefinition("EmpresaMails",
subreport);
localReport.DataSources.Add(new
ReportDataSource("dtEmpresas", empresas));
localReport.DataSources.Add(new
ReportDataSource("dtEmpresasMails", mails));
localReport.SubreportProcessing += new
SubreportProcessingEventHandler(SubReporteMails);
localReport.Refresh();
}
finally
{
if (report != null)
report.Dispose();
if (subreport != null)
subreport.Dispose();
}
var reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;
//The DeviceInfo settings should be changed based on the
reportType
//http://msdn2.microsoft.com/en-us/library/ms155397.aspx
var deviceInfo =
string.Format("<DeviceInfo><OutputFormat>{0}</OutputFormat><PageWidth>8.5in</PageWidth><PageHeight>11in</PageHeight><MarginTop>0.5in</MarginTop><MarginLeft>1in</MarginLeft><MarginRight>1in</MarginRight><MarginBottom>0.5in</MarginBottom></DeviceInfo>",
reportType);
Warning[] warnings;
string[] streams;
//Render the report
var renderedBytes = localReport.Render(
reportType,
deviceInfo,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
//Clear the response stream and write the bytes to the
outputstream
//Set content-disposition to "attachment" so that user is
prompted to take an action on the file (open or save)
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment;
filename=foo." + fileNameExtension);
Response.BinaryWrite(renderedBytes);
Response.End();
}
Gracias!!!