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

Binding to ObjectDataSource not showing data in detail

3 Answers 223 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Terry Burns-Dyson
Top achievements
Rank 1
Terry Burns-Dyson asked on 12 Mar 2012, 09:56 PM
I have an object data source, and I want the data source to be a single object ( I can return IEnumerable<MyDataObject> or MyDataObject) 

What's the correct way of going about this. I want to be able to return a single object, and then just go [=Fields.Field1]. When I'm doing it, I'm getting nothing printing. 

3 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 13 Mar 2012, 01:41 PM
Hi Terry,

The ObjectDataSource works with collections (you can see the supported list here). If you have to return only one object, simply return an array with one element new MyDataObject [] { myObject }; 

Greetings,
Elian
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
0
Karthik Kantharaj
Top achievements
Rank 1
answered on 03 Oct 2013, 11:18 AM
Hi

I came across your answer i have one issue
class apple{
string applename
}
class apple{
string orangename
}
  Telerik.Reporting.ObjectDataSource objectDataSource = new Telerik.Reporting.ObjectDataSource();
            objectDataSource.DataSource = new Object[] { apple,orange}; // Specifying the business object type     

I am able to bind apple object(apple.applename) but not orange
can you please guide me

Karthik.K
0
Elian
Telerik team
answered on 08 Oct 2013, 09:48 AM
Hello Karthik,

The DataSource must be consistent. This means that you have to put either oranges or apples in the list, not both. An alternative solution is to create base class Fruit and use it to feed the DataSource
class Fruit
{
   public string Name{get;set;}
}
 
class Apple : Fruit { }
class Orange : Fruit { }
 

Regards,
Elian
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

Tags
General Discussions
Asked by
Terry Burns-Dyson
Top achievements
Rank 1
Answers by
Elian
Telerik team
Karthik Kantharaj
Top achievements
Rank 1
Share this question
or