I have a report that is bound to a list of objects representing a tract of land. Each tract object has a property that is a list of owners for that tract. I am using the new Table control introduced in Q1 2009 to list the owners of the tract without having to use a subreport.
The Table is in the detail section and I am programatically binding the owners for each tract by handling the ItemDataBinding event of the detail section using the following code:
Telerik.Reporting.Processing.ReportItemBase section = (Telerik.Reporting.Processing.ReportItemBase)sender;
Telerik.Reporting.Processing.Table table = (Telerik.Reporting.Processing.Table)section.ChildElements["tblOwners"];
table.DataSource = section.DataObject["Owners"];
In this case the DataObject is equal to the Tract object currently being bound, as expected, and I'm accessing the Owners property which is the list of tract owners.
This all works fine, however, I now have the need to access a property of the Owner object that is currently being bound. I am using a similar technique to the one I used for the detail section by handling the ItemDataBinding event of the table with the following code:
Telerik.Reporting.Processing.Table table = (Telerik.Reporting.Processing.Table)sender;
Owner tractowner = (Owner)table.DataObject.RawData;
I would expect the DataObject to be for an Owner object, however, at runtime the report throws an exception indicating that it is not possible to cast a Tract object to an object of type Owner. For some reason the table.DataObject is not for an Owner object, but instead for a Tract object even though the table is bound to a list of Owners.
This does not make sense to me. Is this a bug, or am I misunderstanding the use of the DataObject property and if so, how do I access the Owner object that is currently being bound?