ObjectDataSource Generic List properties

3 posts, 1 answers
  1. Craig
    Craig avatar
    2 posts
    Member since:
    Feb 2014

    Posted 28 Jan 2015 Link to this post

    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. Answer
    Stef
    Admin
    Stef avatar
    3610 posts

    Posted 30 Jan 2015 Link to this post

    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.

     
  3. Craig
    Craig avatar
    2 posts
    Member since:
    Feb 2014

    Posted 02 Feb 2015 in reply to Stef Link to this post

    Man, I was close!

    Worked like a champ...   Thank you for the assist  
Back to Top