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

ObjectDataSource Generic List properties

2 Answers 252 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 29 Jan 2015, 04:23 AM
I've searched through the forums and I've found some threads that come close to my question, but none seem to touch on it specifically.  With that, I apologize if my searching skills lack and this ends up being a re-post.

I'm creating a report whose object data source is a List<Person> which has multiple properties, some of which are generic lists... 

i.e.
public class Person {
    public Person() { }
 
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public List<Address> Addresses { get; set; }
    public List<Phone> Phones { get; set; }
 
}

On the report itself, I'd like to bind to the List<Person> via the ObjectDataSource
As far as the display goes, I'd like to have the person's name, Id, etc show up on one line (which works fine), and have the addresses / phones show up under their respective person's record (whether that's by a table or some other control).

In my searches I've found other people doing sub-reports to accomplish this.  This method seems overly complicated to me, especially when there's a reporting table control that can have its own data source.  It would seem I should be able to bind to the Addresses or Phones property of the Person class currently being bound.

Therefore, my question:
Are sub-reports the only way this layout can be accomplished?  
Am I on the right track with the table control (or some other control) that can used as I mentioned?  If so, any links or examples would be handy.

Thanks in advance




2 Answers, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 30 Jan 2015, 04:21 PM
Hi Craig,

Please test the approach from the How to Databind to Collection Properties KB article.

If you want to avoid using other data items in the report, you can also create a user function returning a formatted string for a TextBox or HtmlTextBox item. The function can work with the collection properties which will be handled with custom logic in code.

Let us know if you need any further help.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Craig
Top achievements
Rank 1
answered on 02 Feb 2015, 03:48 PM
Man, I was close!

Worked like a champ...   Thank you for the assist  
Tags
General Discussions
Asked by
Craig
Top achievements
Rank 1
Answers by
Stef
Telerik team
Craig
Top achievements
Rank 1
Share this question
or