binding a nested GridView to field in parent's ObjectDataSource
Posted on 2011-05-02
I have an ASP.NET 4.0 WebForm with a parent/child “nested” GridView – child GridView is the third column of the parent GridView.
My goal is to fetch all the data in one shot – parent and child. To facilitate that, I chose the following format (chose it over XML, which seemed more problematic?)
Item business object (has ID, Value and IsValueRequired properties
Group business object (has ID and IList<Item> properties) - a container of Items
IList<Group> groups => bind to ParentGridView (using ObjectDataSource, dsGroups)
So, I have the “child” IList available in dsGroups. Just can’t figure out how to bind the IList property to ChildGridView (3rd column) and which event is most appropriate - OnRowDataBound of parent?
Suggestions? Would this be any easier using hierarchical XML? My web research seems to suggest that Objects are easier for a GridView to bind to.