c# - RDLC 交替行

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

我一直在开发一个 MVC3 应用程序,最近的一个要求是它有几个动态生成的报告。所以我添加了一个带有报告查看器和几个报告 (.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 请求。但是,尽管我尽了最大的 Firebug 努力,但我还没有找到那个品牌的魔法。

最佳答案

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

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

感觉像 hack,所以我会等一两天再接受这个答案

关于c# - RDLC 交替行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11450331/

相关文章:

c# - 将两个查询合并为一个查询

c# - 如何在 ASP.NET MVC3 中通过 HTTPS 提供静态文件(在 ~/Content 中)

c# - asp.net 网络表单路由无法正常工作

asp.net - 控件何时使用其设计时值进行初始化?

asp.net - 自定义图像按钮控件单击处理程序未触发

c# - 如何调试 ASP.NET 中的 404 错误?

c# - 我应该重载 == 运算符吗?

c# - 创建要在 C# 中编码的 C++ Dll 的最佳实践

C# 编码问题

java - HTTP_USER_AGENT Java/1.6.0_17 生产网站上的奇怪异常