我想在一个视图中显示很多报告,但每个div只显示一个节目。 我有以下控制器代码:
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个地址是有效的,我每次都可以显示其中一个。
哪里可能有问题?
答案 0 :(得分:0)
它显示相同的报告,因为当 DOM完全加载时,它只考虑上一次报告查看器,我的一个代码中也存在同样的问题,那么我尝试了下面,请看它可能对你有所帮助。
<div class="row">
<div class="col-md-6">
<div class="col-md-12">
@Html.Partial("DisplayClassesListFilter", null, new ViewDataDictionary { { "GridId", "classList1" }, { "GridParentDivId", "divClassList1" } })
</div>
<div class="col-md-12 classlist1 m-bottom25">
@Html.Partial("_ClassListWithoutPaging", null, new ViewDataDictionary { { "DisplayClasses", true }, { "Controller", "DisplayClasses" }, { "Action", "GetAllClassWithoutPaging" }, { "SearchFunctionName", "BuildSearchCriteriaDisplayClasses1" }, { "GridId", "classList1" }, { "GridParentDivId", "divClassList1" } })
</div>
</div>
<div class="col-md-6">
<div class="col-md-12">
@Html.Partial("DisplayClassesListFilter", null, new ViewDataDictionary { { "GridId", "classList2" }, { "GridParentDivId", "divClassList2" } })
</div>
<div class="col-md-12 classlist2 m-bottom25">
@Html.Partial("_ClassListWithoutPaging", null, new ViewDataDictionary { { "DisplayClasses", true }, { "Controller", "DisplayClasses" }, { "Action", "GetAllClassWithoutPaging" }, { "SearchFunctionName", "BuildSearchCriteriaDisplayClasses2" }, { "GridId", "classList2" }, { "GridParentDivId", "divClassList2" } })
</div>
</div>
</div>