【问题标题】:RDLC Alternating rowsRDLC 交替行
【发布时间】:2012-07-12 10:56:25
【问题描述】:

我一直在开发一个 MVC3 应用程序,最近的一个要求是它有几个动态生成的报告。所以我添加了一个带有reportviewer 和几个报告(.rdlc)的webbform。但是当我尝试设置条件行填充时,例如

=IIf(RowNumber(Nothing) Mod 2, "Blue", "Red") // Won't acctually use those colors but you get the gist

但生成的背景仍然是白色的。 我在一个真正的蓝色 Webform 应用程序中尝试了完全相同的 Webform,并从那里正确呈现。我检查了我的 MVC 项目是否包含我的 Webforms 测试项目中使用的每个引用,并将 .aspx 和 .rdlc 添加到“Global.asax.cs”中被忽略的路由。

为什么是混合恐怖?
由于性能原因,我无法从客户端报告生成更改为服务器端,也无法使用不同/远程服务器,因为环境(是复数)缺乏带宽和连接性。而且我不希望只为报表查看器添加单独的应用程序池(再次是性能问题)。

编辑1:

全球.asax

public class MvcApplication : System.Web.HttpApplication {
    public static void RegisterGlobalFilters ( GlobalFilterCollection filters ) {
        filters.Add(new HandleErrorAttribute());
    }

    public static void RegisterRoutes ( RouteCollection routes ) {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
        routes.IgnoreRoute("{resource}.rdlc/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
        );

    }

    protected void Application_Start () {
        AreaRegistration.RegisterAllAreas();

        RegisterGlobalFilters(GlobalFilters.Filters);
        RegisterRoutes(RouteTable.Routes);
    }
}

报告.aspx ……

</rsweb:ReportViewer>
<asp:XmlDataSource ID="reportsDS" runat="server" 
        DataFile="~/Reporting/ReportSettings/Reportlist.xml" 
        XPath="Reports/Report" />
<asp:ScriptManager ID="scriptmanager" runat="server" />
....

报告.aspx.cs

// Some configuration initialization and the regular Page_Init + Page_Load assigning
// default values

protected void changeReport() {
    ReportViewer.Reset();
    ReportDataSource RDS = new ReportDataSource( /* grabbed from a combination of applicationsettings and input parameters */
    ReportViewer.LocalReport./* adding datasource and setting paths, names, etc. */
}

编辑2: 添加了代码以更好地了解我正在做的事情,但看到代码在从 Webforms 项目发布时确实有效,我猜 ReportViewer 执行了 Global.asax 并不特别喜欢的某种 Blackmagic 请求。但是,尽管我尽了最大的努力,我还没有找到那个魔法品牌。

【问题讨论】:

  • 你能在上下文中发布更多代码吗?
  • 为上下文添加了一些代码,但看到我已经设法获得了 Report.aspx 的 Carboncopy,它的报告可以从 Webforms 应用程序正确呈现,这似乎很奇怪(至少对我来说)问题将在 Global.asax 以外的任何地方或某些引用冲突

标签: c# asp.net-mvc-3 webforms rdlc


【解决方案1】:

我设法通过修改 Page_Init 解决了这个问题

protected void Page_Init( object sender, EventArgs e ) {
    ...
    ReportViewer.LocalReport.SetBasePermissionsForSandboxAppDomain(new PermissionSet(PermissionState.Unrestricted));
    ...
}

感觉像个黑客,所以我会等待一两天才能接受这个答案

【讨论】:

    猜你喜欢
    • 2015-12-06
    • 2013-08-18
    • 1970-01-01
    • 1970-01-01
    • 2019-02-02
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    • 2011-07-30
    相关资源
    最近更新 更多