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

[Solved] Binding columns from all items in a list

1 Answer 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
melkorman
Top achievements
Rank 1
melkorman asked on 09 Sep 2009, 07:03 AM
Hello,

I'm not sure if this question has been asked before, but anyway;

I have an ObjectDataSource that I want to bind to a Grid. The objects in the data source has one property that is a list, and I would like all of the items in that list to become their own columns. Lets pretend it looks like this:

public class Foo
{
   public int Id { get; set; }
   public string X { get; set; }
   public List<Bar> Bars { get; set; }
}

public class Bar
{
   public int Id { get; set; }
   public string Y { get; set; }
}

If my data source has a collection of Foo objects, can I make the grid show columns for the following values?
Foo.Id, Foo.X, Foo.Bars[0].Y, Foo.Bars[1].Y, ..., Foo.Bars[n].Y

Thanks a lot!

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetoslav
Telerik team
answered on 10 Sep 2009, 01:59 PM
Hello Linus,

This scenario is possible - please, review the attached sample for a very basic demonstration of it.

Best wishes,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
melkorman
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or