2016-06-30 52 views
0

我有一個主報表,其中包含兩個從ASP.NET MVC 5.0(VS 2015)調用的子報表,但有時主報表缺少來自其中一個子報表的數據(不是兩個)。爲什麼在導出到pdf時ReportViewer中的子報表中缺少數據

如果我重新加載頁面,則會顯示所有數據。

什麼是錯誤?

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

回答

0

今天,我添加了這些行:

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

我認爲這是解決方案,因爲今天重新加載頁面。

相關問題