如何调试 Rdlc 表达式错误 - C#

How to debug Rdlc expression errors - C#

通过在 SO 上阅读几个问题和答案,我知道 IIF 执行 true 和 false。我似乎无法理解如何正确检查和处理 null。

这是我试过的几个给出#Error 的语句,

=switch(
        First(Fields!ShelfLife.Value, "DQA")="N/A", "N/A",
        First(Fields!ShelfLife.Value, "DQA")<>"N/A", (FormatNumber(First(Fields!ShelfLife.Value, "DQA"), 1))
    )

=IIf(
    First(Fields!ShelfLife.Value, "DQA")="N/A",
    "N/A",
    IIf(
        IsNothing((First(Fields!ShelfLife.Value, "DQA"))),
        "Test",
        (FormatNumber(First(Fields!ShelfLife.Value, "DQA"), 1))
    )
)

有没有办法获得某种消息,说明该声明的问题所在?同样重要的是,如何解决我收到的错误?

我们 运行 不久前遇到过这样的问题。它过去不是也不是完全理想,但我们的工作涉及将两个数据源传递给报告,如下所示:

this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("first",  Source1 as DataTable));
this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("second",  Source2 as DataTable));

为了进一步解释这一点,Source1 和 Source 2 是相同的。在上面几行之前,对 Source1 进行一些检查和操作。所以表达式应该是这样的:

=switch(
        First(Fields!ShelfLife.Value, "DQA1")="N/A", "N/A",
        First(Fields!ShelfLife.Value, "DQA1")<>"N/A", (FormatNumber(First(Fields!ShelfLife.Value, "DQA2"), 1))
    )