This is a migrated thread and some comments may be shown as answers.

Bind data to table form nested objects nested list

1 Answer 244 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Attila
Top achievements
Rank 1
Attila asked on 03 Nov 2013, 10:32 AM
These are my two classes

    public class A
    {
        public string Nev { get; set; }
        public List<B> Adatok = new List<B>();
        public double Brutto { get; set; }
        public double Ado { get; set; }
        public double Netto { get; set; }
        public int DolgozottNapokSzama { get; set; }
        public int IgazolatlanNapokSzama { get; set; }
        public string Datum { get; set; }
    }

    public class B
    {
        public string Beosztas { get; set; }
        public double Oradij { get; set; }
        public double Oraszam { get; set; }
        public double PotlekoltOrak { get; set; }
        public double PotlekmentesOrak { get; set; }
        public int Unnepnap { get; set; }
        public int Igazolatlan { get; set; }
        public double BruttoMunakber { get; set; }
        public double PotlekNormal { get; set; }
        public double PotlekUnnep { get; set; }
        public double Brutto { get; set; }
    }

I need to view the nested List B from object A view table. I did the binding to the table

DataSource = Fields.Adatok

as I read on the forums, but it not working. I got the message:

,,The expression contains object "Adatok" that is not definied in the current context,, .

I would appreciate some more detailed answer. Thnx.

1 Answer, 1 is accepted

Sort by
0
Attila
Top achievements
Rank 1
answered on 03 Nov 2013, 08:43 PM
public class A
    {
        public string Nev { get; set; }
        public List<B> Adatok { get; set; }
        public double Brutto { get; set; }
        public double Ado { get; set; }
        public double Netto { get; set; }
        public int DolgozottNapokSzama { get; set; }
        public int IgazolatlanNapokSzama { get; set; }
        public string Datum { get; set; }

        public JelentesHaviJelenletiIvTypeIData()
        {
            Adatok = new List<B>();
        }
    }

Just needed to change the class A to this one and everything is worked fine.
Tags
General Discussions
Asked by
Attila
Top achievements
Rank 1
Answers by
Attila
Top achievements
Rank 1
Share this question
or