XtraReport 未显示任何数据
Posted
技术标签:
【中文标题】XtraReport 未显示任何数据【英文标题】:XtraReport not showing any data 【发布时间】:2015-11-09 14:12:12 【问题描述】:我已按照本文档link 中的说明进行操作。 xtrareport 显示框工具栏,但不显示任何数据。我做错了什么?
在我的 HomeController.cs 中
public ActionResult Index()
ViewBag.Message = "Welcome to DevExpress Extensions for ASP.NET MVC!";
ViewData["Report"] = new DXApplication.Reports.XtraReport1();
return View();
public ActionResult DocumentViewerPartial()
ViewData["Report"] = new DXApplication.Reports.XtraReport1();
return PartialView("DocumentViewerPartial");
public ActionResult ExportDocumentViewer()
return DevExpress.Web.Mvc.DocumentViewerExtension.ExportTo(new DXApplication.Reports.XtraReport1());
DocumentViewerPartial.cs
**@html.DevExpress().DocumentViewer(settings =>
settings.Name = "DocumentViewer";
settings.Report = (DXApplication.Reports.XtraReport1)ViewData["Reports"];
settings.CallbackRouteValues = new Controller = "Home", Action = "DocumentViewerPartial" ;
settings.ExportRouteValues = new Controller = "Home", Action = "ExportDocumentViewer" ;
).GetHtml()**
还有Index.cshtml
ViewBag.Title = "Home Page";
@ViewBag.Message
@Html.Action("DocumentViewerPartial")
【问题讨论】:
【参考方案1】:尝试更改 DocumentViewerPartial.cs
ViewData["Reports"]
与 ViewData["Report"]
【讨论】:
【参考方案2】:在 XtraReport1 中你是怎么写的?如果您提供您的代码 XtraReport1 或为我们提供一个简单的案例演示,那就太好了。 我在你的控制器中看到,如果你写它,它将获得第三个数据: ViewData["Report"] = new DXApplication.Reports.XtraReport1();
-
Index()中的第一个
DocumentViewerPartial() 中的第二个
ExportDocumentViewer() 中的第三个
准备好你只需要第一次获取数据,你可以写:
public ActionResult Index()
ViewBag.Message = "Welcome to DevExpress Extensions for ASP.NET MVC!";
return View();
public ActionResult DocumentViewerPartial()
Session["Report"] = new DXApplication.Reports.XtraReport1();
return PartialView("DocumentViewerPartial");
public ActionResult ExportDocumentViewer()
return DevExpress.Web.Mvc.DocumentViewerExtension.ExportTo(Session["Report"] as XtraReport1());
然后在 DocumentViewerPartial.cs 中编辑:
@Html.DevExpress().DocumentViewer(settings =>
settings.Name = "DocumentViewer";
settings.Report = (DXApplication.Reports.XtraReport1)Session["Reports"];
settings.CallbackRouteValues = new Controller = "Home", Action = "DocumentViewerPartial" ;
settings.ExportRouteValues = new Controller = "Home", Action = "ExportDocumentViewer" ;).GetHtml()
然后在你调用的文件 Index.cshtml 中最终:
@Html.Partial("ExportDocumentViewer")
@Html.Partial("DocumentViewerPartial")
请进行相应的修改并让我知道你的结果。
【讨论】:
以上是关于XtraReport 未显示任何数据的主要内容,如果未能解决你的问题,请参考以下文章