1
我想在一個視圖中顯示大量報告,但在每個div中只顯示一個。 我有以下的控制器代碼:ViewBag在一個視圖中顯示許多報告
ReportViewer rptViewer1 = new ReportViewer();
rptViewer1.ProcessingMode = ProcessingMode.Remote;
rptViewer1.SizeToReportContent = true;
rptViewer1.ZoomMode = ZoomMode.FullPage;
rptViewer1.AsyncRendering = true;
rptViewer1.ServerReport.ReportServerUrl = new Uri("MyServerAddress");
rptViewer1.ServerReport.ReportPath = "MyPath";
rptViewer1.ServerReport.ReportServerCredentials = new ReportViewerCredentials("MyCredentials");
ViewBag.ReportViewer1 = rptViewer1;
ReportViewer rptViewer = new ReportViewer();
rptViewer.ProcessingMode = ProcessingMode.Remote;
rptViewer.SizeToReportContent = true;
rptViewer.ZoomMode = ZoomMode.FullPage;
rptViewer.AsyncRendering = true;
rptViewer.ServerReport.ReportServerUrl = new Uri("MyServerAddress2");
rptViewer.ServerReport.ReportPath = "MyPath2";
rptViewer.ServerReport.ReportServerCredentials = new ReportViewerCredentials("MyCredentials");
ViewBag.ReportViewer = rptViewer;
return View();
和視圖代碼:
<div class="col-md-4">
@Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer, new { frameborder = "0", width = "500", height = "500", style = "overflow:hidden;", scrolling = "no" })
</div>
<div class="col-md-4">
@Html.ReportViewer(ViewBag.ReportViewer1 as Microsoft.Reporting.WebForms.ReportViewer, new { frameborder = "0", width = "500", height = "500", style = "overflow:hidden;", scrolling = "no" })
</div>
<div class="col-md-4">
@Html.ReportViewer(ViewBag.ReportViewer as Microsoft.Reporting.WebForms.ReportViewer, new { frameborder = "0", width = "500", height = "500", style = "overflow:hidden;", scrolling = "no" })
</div>
當我運行的網頁我有一個
3條相同
報告行。我不知道問題出在哪裏,爲什麼我不能顯示2個獨特的報告。我沒有看到它的迷戀,因爲它編譯沒有問題。 2個報告地址是有效的,每次我都可以顯示其中的一個。
哪裏可以成爲問題?
我可以在哪裏找到您的解決方案ReportViewer? – Sowiarz
在視圖代碼中,您必須根據傳遞的ViewDataDictionary在報表查看器中作出決定 –
您可以向我展示如何將其固定在下面的代碼中? – Sowiarz