I have a List of custom object, which consist of a custom list.
class person{
string name;
int age;
List<friend> allMyFriends;
}
class friend{
string name;
string address;
}
I'trying to bind a list of these objects to a GridView and the Grid should create for each friend a column and write the name in it. If some people have the same frined the grid shouldn't create a seperate column, but use the existing one. You know what I mean. (The classes are just some sample classes to simplify my case)
Is there a way to dynamically customize the binding?
I can change the class definitions and so on, if they need to inherit from some interfaces or so on.
I googled a lot, but no example really seemed to cover this case.
Could the use of a objectSourceControl solve my problem in some way?
Update:
To give some more information: In the end I have a list of persons, while each person in the list has a list of friends.
List<person> allPerson = new List<person>();
// fill the list
Grid.DataSource = allPerson;
Grid.DataBind()
The table should have columns for each friend and the rows are the person. Where a person has a friend a cross (or whatever) needs to be placed in the grid.
friend1 friend2
x peter
x x adam
At the moment a intercept the RowDataBound event and since the binding only creates the rows with the names and not the columns, because the only property on my person object is the name. Is there a way to force the binding to look through the List Property in the person objects and create a column for each of them.