RDLC (VS 2010) How to Access Nested Classes or Arrays in DataObjects

How can I access the TD.SubNumber and Numbers [] property in RDLC? I keep getting #Error in 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; }
    }
}
+3
source share
1 answer

Add the "serializable" attribute to each of the nested classes, then you can refer to 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; }
    }
}
+1
source

Source: https://habr.com/ru/post/1734858/


All Articles