RDLC交替行

时间:2012-07-12 10:56:26

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

我一直在研究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'中忽略的路由。

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

EDIT1:

Global.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);
    }
}

Report.aspx     ....     

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

Report.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. */
}

EDIT2: 添加了代码,以便为我正在做的事情提供更好的上下文,但是当从Webforms项目发布时看到代码实际上正常工作我猜测ReportViewer会执行某种类型的Blackmagic请求,而Global.asax并不特别喜欢。但尽管我做了最好的萤火虫努力,但我还没有找到那种魔力。

1 个答案:

答案 0 :(得分:1)

我设法通过修改Page_Init

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

感觉像是一个黑客,所以在接受这个答案之前我会待一两天