XtraReport没有显示任何数据

时间:2015-08-17 02:23:30

标签: c# asp.net-mvc devexpress

我已按照本文档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")

2 个答案:

答案 0 :(得分:0)

尝试更改DocumentViewerPartial.cs ViewData["Reports"]ViewData["Report"]

。{

答案 1 :(得分:0)

在XtraReport1中你怎么写?如果你提供你的代码XtraReport1或者为我们提供一个简单的案例演示,那就太好了。 我在你的控制器中看到,如果你写这个,它会得到第三个数据: ViewData [“Report”] = new DXApplication.Reports.XtraReport1();

  1. Index()
  2. 中的第一个
  3. DocumentViewerPartial()
  4. 中的第二个
  5. ExportDocumentViewer()中的第三个
  6. 准备好你只需要获取数据第一,你可以写:

    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")
    

    请执行相应的修改,并告诉我您的结果。