2016-04-18 22 views
0

サブレポートをメインレポートに設定したいのですが、サブレポートのデータセットに問題があります。私の主な報告の行動。Reportviewerのサブレポートが機能しません

public ActionResult ExibirRelatorioProgramaSol(FormCollection form) 
    { 
     DateTime dtInicial = DateTime.Parse(form["dt_inicio"]); 
     DateTime dtFinal = DateTime.Parse(form["dt_fim"]); 
     int idLista = form["ddl_Lista"].ConvertValueForm<int>(); 
     var avaliacao = _appServicoAvaliacaoSetor.ObterAvaliacoes(dtInicial, dtFinal, idLista); 
     var relatorio = _appServicoAvaliacaoSetor.GerarRelatorioProgramaSol(dtInicial, dtFinal, idLista); 

     var viewer = new Microsoft.Reporting.WebForms.ReportViewer(); 
     viewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; 
     viewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + "/Report/ReportProgramaSol.rdlc"; 
     viewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(RenderizaSubRelatorioPedido); 
     viewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("ProgramaSol", relatorio.ToList())); 
     viewer.SizeToReportContent = true; 
     viewer.Width = System.Web.UI.WebControls.Unit.Percentage(100); 
     viewer.Height = System.Web.UI.WebControls.Unit.Percentage(100); 

     ViewBag.ReportViewer = viewer; 

     return View(); 
    } 

私のサブレポートのアクション:

private void RenderizaSubRelatorioPedido(object sender, SubreportProcessingEventArgs e) 
    { 
     int idEmpresa = Convert.ToInt32("2"); 

     e.DataSources.Add(new ReportDataSource("empresa", 
         _appServicoEmpresa.ObterEntidadePor(i => i.Id == idEmpresa))); 
    } 

エラー:

Failure data recovery for the sub- report ' subreport1 ' , located at: C : \ Projects \ Samich \ VisualStudioOnLine \ Vanessa \ Samich Projects C# \ EMS - Audit Management System - Copy \ EMS - Audit Management System \ Report \ ReportHeader.rdlc . Check the log files for more information .

を誰かが私を助けることができますか?

+0

Ahサブレポート...有用なエラーメッセージの点ではあまり効果がありません。私がやったことの1つは、完全にクリーンなサブレポート(例えば、データソース/パラメータやその他のものがない)から始めてゆっくりとゆっくりと始めることです...非常にゆっくりと...さまざまな部分を追加してください。パラメータから始めてください...デザイナーでそれらをバインドする必要があります、そして、彼らはおそらく外側のレポートから来るでしょう。次に、データソースを追加します。死ぬものを見てそこから行ってください。 – BlackjacketMack

+0

私はすべてを試みましたが、何も動作しません。私は本当に助けが必要です。 =( –

答えて

0

私は上記と同じ問題を持っている - ここで私はこれまで試したものを

です(私はMVCに移行しています)、既存のWindowsアプリケーションがRDLCはWindowsのレポートビューアコントロールでOKレンダリングされ報告しました。

MVCにコードを移植すると、上記のようなサブレポートに問題があります。サブレポートを表示できないというメッセージだけで、問題のログやその他のポインタを見つけることができません。

私は

@using ReportViewerForMvc; 

サブレポートデータが処理イベント

rpt.SubreportProcessing += LocalReport_SubreportProcessing; 

MVC版でに追加され、次のビューアを使用しています、上記のイベントがコントローラーに呼び出されることはありません。

これを解決する別の試みでは、C#をCSHTMLページのコードブロックに移動し、イベントやその他のメソッドをデリゲートとアクションブロックにラップしましたが、同じ問題が発生します。

rpt.SubreportProcessing += (object sender, SubreportProcessingEventArgs e) => 
    { 
... 

レポートプロセスの実行場所はわかりませんが、コントローラまたはCSHTMLコードのいずれかでイベントハンドラが呼び出されることはありません。

ビューを返す代わりにコントローラでレポートをレンダリングすると、レポートが正しく作成され、PDFがブラウザに表示されます。

Warning[] warnings; 
    string mimeType; 
    string[] streamids; 
    string encoding; 
    string filenameExtension;   

    var bytes = rpt.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); 

    return new System.Web.Mvc.FileContentResult(bytes, mimeType); 

私はまた、サブレポートのイベントハンドラを呼び出すと、処理に必要なデータのすべてを持っているように見えます、Windowsのバージョンと同じコードを実行している別のAPSXページを作成しました。ただし、レポートビューアにはレポートは表示されません(レポートには1ページあり)。 ASPXページデザイナで、コントロールは、これまでのところ、その後

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Reports.aspx.cs" Inherits="Cass3Web.Reports" %> 

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> 


<!DOCTYPE html> 


<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
     <asp:ScriptManager ID="ScriptManager1" runat="server"> 
      <Scripts> 
       <asp:ScriptReference Assembly="ReportViewerForMvc" Name="ReportViewerForMvc.Scripts.PostMessage.js" /> 
      </Scripts>     
     </asp:ScriptManager> 
     <div style="height: 600px; width: 900px; border: 1px solid silver;"> 
      <rsweb:ReportViewer ID="rv" runat="server" Height="600" Width="900" AsyncRendering="false"></rsweb:ReportViewer> 
     </div> 
    </form> 
</body> 
</html> 

それが作成できないと言って(ツールボックスのレポートビューアーコントロールがありません)エラーメッセージ、運

を持って

私は、MVCページがレンダリングされると、レポートがすぐに読み込まれないことに気付きます。タイマーで待ち時間があり、数秒後にビジー状態のアイコンが表示され、レポートの処理が続行されます(サブレポートを除いたもの)

私はこれをもう一度見せますが、成功

0

ソリューションを取得

アンASPXフォーム "ReportViewerWebForm.aspxは" NuGetによってプロジェクトに追加されますが見つかりました。これは、MVCビューからレポートをレンダリングするために呼び出されます。このページを編集すると、サブレポートプロセスを呼び出すことができます。

ReportViewerWebForm.aspxにはコードビハインドページはありませんが、背後で動作するクラス「ReportViewerForMvc.ReportViewerWebForm」を継承しています。

ページクラスファイル "ReportViewerWebForm.aspx.cs"(および完全性についてはデザイナーファイル "ReportViewerWebForm.aspx.designer.cs")を追加し、コードビハインドクラスから継承するようにASPXページを変更しました。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReportViewerWebForm.aspx.cs" Inherits="YourNamespace.ReportViewerWebForm" %> 

私は、ページクラスは「ReportViewerForMvc.ReportViewerWebForm」から継承するようにコードビハインドに更新され、サブレポート処理イベントを配線するOn_Loadの上書きを作成しました。データは、サブレポートに追加された場合、あなただけのレポートを1つ持っている場合は、このイベントの中でハンドラが

using Microsoft.Reporting.WebForms; 
namespace YourNamespace 
{ 
    public partial class ReportViewerWebForm : ReportViewerForMvc.ReportViewerWebForm 
    { 

     protected override void OnLoad(EventArgs e) 
     { 
      base.OnLoad(e); 

      ReportViewer1.LocalReport.SubreportProcessing += LocalReport_SubreportProcessing; 
     } 


     private void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e) 
     { 
      ReportDataSource rds = new ReportDataSource("SubReport_DatasetName_Here", yourData); 
      e.DataSources.Add(rds); 
     } 
    } 
} 

これは正常に動作しているが、複数のレポートをサポートするために、あなたはで提供するデータを知っておく必要があります各ケース。短期間では、私は「Reportviewer1.LocalReport.DisplayName」に一意の名前を設定します。

関連する問題