Hi!
After a quick search I discovered that many-to-many relationships aren't supported in the GridView (using data binding). But, I still need to display such data, and wonder what your recomendations are to accomplish this.
Scenario:
Two classes:
- Concert
- City
The City can host zero or many Concerts, and a Concert man be held in zero or many cities. Class definitions below:
I load the all the Cities into a separate List<City>, and all Concerts into another List<Concert> and via another method I resolve the many-to-many relationships:
I have only created ONE object instance per City and ONE object instance per Concert. The ResolveRelationships method just reads a relation-table and populates the City.Concerts and Concert.Cities collections. The City.Concerts and Concert.Cities collections just contain references to the objects originally loaded into AllCities and AllConcerts.
Now I want to display this into a grid. The MasterGridView can contain the Concerts and the ChildGridView can contain the Cities (or vice versa).
What are your recomendations on how to accomplish this? Manually create the grid or use some kind of object datasource?
Thanks in advance,
Johan
After a quick search I discovered that many-to-many relationships aren't supported in the GridView (using data binding). But, I still need to display such data, and wonder what your recomendations are to accomplish this.
Scenario:
Two classes:
- Concert
- City
The City can host zero or many Concerts, and a Concert man be held in zero or many cities. Class definitions below:
class Concert |
{ |
string Name; |
List<City> Cities; |
} |
class City |
{ |
string Name; |
List<Concert> Concerts; |
} |
I load the all the Cities into a separate List<City>, and all Concerts into another List<Concert> and via another method I resolve the many-to-many relationships:
void LoadData() |
{ |
List<City> AllCities = LoadAllCities(); // Load data from database |
List<Concert> AllConcerts = LoadAllConcerts(); // Load data from database |
ResolveRelationships(AllCities, AllConcerts); // Resolve many-to-many relationship |
} |
Now I want to display this into a grid. The MasterGridView can contain the Concerts and the ChildGridView can contain the Cities (or vice versa).
What are your recomendations on how to accomplish this? Manually create the grid or use some kind of object datasource?
Thanks in advance,
Johan