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

[Solved] problem databinding List datatype

4 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tom Parks
Top achievements
Rank 1
Tom Parks asked on 09 Jun 2009, 08:02 PM
I'm trying to bind data from a two-dimensional List structure to a grid but its not working out.  This is what I'm trying to do in the NeedDataSource event for my grid:

            List<List<object>> rows = new List<List<object>>();  
 
            List<object> list1 = new List<object>();  
            list1.Add("testing1");  
            list1.Add("testing2");  
            List<object> list2 = new List<object>();  
            list2.Add("testing3");  
            list2.Add("testing=42");  
            rows.Add(list1);  
            rows.Add(list2);  
            radGrid.DataSource = rows; 

I'm hoping to get output that looks like:

testing1   testing2
testing3   testing=42

Instead I get:

Capacity  Count
4               2
4 2

Can anyone tell me how I can do something like this without using a DataSet or DataReader?

4 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 12 Jun 2009, 03:13 PM
Hi Tom Parks,

I am afraid that the desired result could be hardly achieved with such data source. I suggest that you try replacing the inner List<object> with custom class with properties instead.
Additionally, you can find more information on data-binding RadGrid to different objects here.

I hope this helps.

Kind regards,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Rubens
Top achievements
Rank 1
answered on 15 Jun 2009, 01:06 AM
Hi,

I've a similar scenario; consider, for instance, a custom object "Customer" with an "Orders" property. It's possible to bind this object to a master-detail grid? In my case, I already have the child collection loaded, so I don't want to read it again.

TIA,

Rubens
0
Iana Tsolova
Telerik team
answered on 15 Jun 2009, 01:48 PM
Hi Rubens,

I am afraid that you need to handle the DetailTableDataBind event and additionally assign the particular detail GridTableView corresponding Orders collection. However, you can retrieve the Customers collection from database on NeedDataSource event and save it in a private variable. Then use this variable in the DetailTableDataBind.
Find more about dynamic hierarchical grid data-binding here.

Sincerely yours,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Rubens
Top achievements
Rank 1
answered on 21 Jun 2009, 02:06 PM
Hi Iana,

I found two very useful links about that task: How To: RadGrid hierarchy from objects hierarchy and Mixed Hierarchy Loading ; reading them both helped me to accomplish my task.

Thank you for your help,

Rubens
Tags
Grid
Asked by
Tom Parks
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Rubens
Top achievements
Rank 1
Share this question
or