
I want to bind detail table of radgrid with collection of objects which is itself a property of master table's object.
For example:
I am binding grid with "Product" objects. "Product" object has one property which is a collection of discounts. I want to bind this discount collection for each product row in detail table.
All such examples on Telerik site are using SqlDataSource, ObjectdataSource which passes IDs to server side method which gives the dataset.
Here I have "Discount" collection filled up already when i am binding "Products" to the grid, so my concern is how can I use this "discount" collection to fill up my detail table.
Thanks in advance,
Vinayak
5 Answers, 1 is accepted
If none of the standard datasource controls is capable to cater for the data which you want to pass to the control, you can use the NeedDataSource/DetailTableDataBind event handlers, to pass appropriate subsets of data to the grid. This approach is demonstrated in the following example:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/detailtabledatabind/defaultcs.aspx
I hope this gets you started properly.
Best wishes,
Yavor
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.

Thanks for the reply. But i think I should explain my problem more precisely.
I have data in my hand at first shot and I want to bind master table and detail table at one shot on page load only.
Data like
<product name="car">
<toyota></toyota>
<honda></honda>
</product>
<product name="bike">
<yamaha></yamaha>
<harley></harley>
</product>
I have all this data with me on page load. For master table I want to bind list of products and in detail table I want to bind brandnames.I want to bind this data on page load only. Also if I want to show the all detail tables in expanded mode, can I do that?
thanks,
Vinayak
When the data is passed to the grid control, this cannot be done in a simple pass. That is, when using the NeedDataSource/DetailTableDataBind event handlers, the relevant data is passed to the grid when only when needed. For example, on first load, only the NeedDataSource event handler is raised. Then, when you expand a level, the DetailTableDataBind event is raised. This allows you to pass the required data as needed, in relation to a given master record. Let me know how this approach meets your requirements, or where it falls short.
Best wishes,
Yavor
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.

I agree that this approch is most optimized. The only concern I had that, if I have all data in hand at first load only why I need to send new request for sql server / xml datasource to fetch data for detail table.
( I have list of products and vendor list for each product on load, but to bind vendor list to detail table I need to fetch data from sql server again through product Id.)
For the time being I have to keep my datasource in session and on detail table data bind event I am accessing this datasource from session instead of sending request to sql server again.
Is there any better way you can suggest?
Thanks,
Vinayak
If you need the detail tables to be data-bound on initial load, just set the HierarchyLoadMode for the grid to Client or ServerBind.
More information you can find at the following help topic:
http://www.telerik.com/help/aspnet-ajax/grdhierarchyloadmodes.html
I hope this helps.
Greetings,
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.