RDLC (VS 2010) 如何访问 DataObject 上的嵌套类或数组

发布于 2024-08-22 23:19:09 字数 738 浏览 11 评论 0原文

如何访问 RDLC 上的 TD.SubNumber 属性和 Numbers[]?我的表达式“=Fields!TD.Value.SubNumber”和“=Fields!Numbers.Value(0)”不断收到#Error。

public class TestData
{

    TestSubData tdata = new TestSubData();
    public TestSubData TD
    {
        get { return tdata; }
        set { tdata = value; }
    }

    string m_Description;
    public string Description
    {
        get { return m_Description; }
        set { m_Description = value; }
    }

    int[] m_Numbers = new int[12];
    public int?[] Numbers
    {
        get { return m_Numbers; }
    }


}
public class TestSubData
{
    int x;
    public TestSubData()
    { 
    }

    public int SubNumber
    {
        get { return x; }
        set { x = value; }
    }
}

How can I access the TD.SubNumber property and Numbers[] on RDLC? I keep getting #Error on my expressions "=Fields!TD.Value.SubNumber" and "=Fields!Numbers.Value(0)".

public class TestData
{

    TestSubData tdata = new TestSubData();
    public TestSubData TD
    {
        get { return tdata; }
        set { tdata = value; }
    }

    string m_Description;
    public string Description
    {
        get { return m_Description; }
        set { m_Description = value; }
    }

    int[] m_Numbers = new int[12];
    public int?[] Numbers
    {
        get { return m_Numbers; }
    }


}
public class TestSubData
{
    int x;
    public TestSubData()
    { 
    }

    public int SubNumber
    {
        get { return x; }
        set { x = value; }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

末が日狂欢 2024-08-29 23:19:09

向每个嵌套类添加“可序列化”属性,然后您可以使用以下表达式进行引用:

“=Fields!TD.Value.SubNumber”

[Serializable()]
public class TestData
{
    TestSubData tdata = new TestSubData();
    public TestSubData TD
    {
        get { return tdata; }
        set { tdata = value; }
    }

    string m_Description;
    public string Description
    {
        get { return m_Description; }
        set { m_Description = value; }
    }

    int[] m_Numbers = new int[12];
    public int?[] Numbers
    {
        get { return m_Numbers; }
    }
}

[Serializable()]
public class TestSubData
{
    int x;
    public TestSubData()
    { 
    }

    public int SubNumber
    {
        get { return x; }
        set { x = value; }
    }
}

Add the "serializable" attribute to each of the nested classes, then you can reference with expressions such as:

"=Fields!TD.Value.SubNumber"

[Serializable()]
public class TestData
{
    TestSubData tdata = new TestSubData();
    public TestSubData TD
    {
        get { return tdata; }
        set { tdata = value; }
    }

    string m_Description;
    public string Description
    {
        get { return m_Description; }
        set { m_Description = value; }
    }

    int[] m_Numbers = new int[12];
    public int?[] Numbers
    {
        get { return m_Numbers; }
    }
}

[Serializable()]
public class TestSubData
{
    int x;
    public TestSubData()
    { 
    }

    public int SubNumber
    {
        get { return x; }
        set { x = value; }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文