Why missing data in ReportViewer with subreports when export to pdf

214 Views Asked by At

I've a master report that contains two subreports called from ASP.NET MVC 5.0 (VS 2015) but sometimes the master report is missing data from one of subreportes (not both).

If I reload the page, all data displayed.

What is the error?

    LocalReport reportViewerLocal = new LocalReport();
    ...
    reportViewerLocal.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessingComprobanteRol);
    ...
    Response.Clear();
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "inline");
    Response.AddHeader("Content-Length", renderedBytes.Length.ToString());
    Response.BinaryWrite(renderedBytes);


    void SubreportProcessingComprobanteRol(object sender, SubreportProcessingEventArgs e)
    {

       // Defino Parametro
       string param1 = e.Parameters["ParamSubReporteIdPersona"].Values[0];
       string param2 = e.Parameters["ParamSubReporteTipoMovimiento"].Values[0];

       // Designo DataSet según parametro
       string dataSourceName = e.DataSourceNames[0];
       List<MovimientoRolModel> lista =  ((IEnumerable) dataSourceDetalleComprobanteRol).Cast<MovimientoRolModel>().ToList();
       List<MovimientoRolModel> movimiento = lista.Where(p => p.IdPersona == Convert.ToInt32(param1) && p.TipoMovimiento == Convert.ToInt32(param2)).ToList();
       e.DataSources.Clear();
       ReportDataSource datasourceDetalle = new ReportDataSource(dataSourceName, movimiento);
       e.DataSources.Add(datasourceDetalle);
    }

enter image description here

1

There are 1 best solutions below

0
MAyuqui On

Today, I added these lines:

Response.Clear();
...
Response.AddHeader("Content-Length", renderedBytes.Length.ToString());

I think this is the solution because today reloaded the page.