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

get the object from objectDataSource

2 Answers 89 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 13 Dec 2012, 05:31 PM
I have a class which I am attaching to my report using an ObjectDataSource.
In the designer I see that the type of the datasource is set to that of this class

this.objectDataSource1.DataSource = typeof(Acme.Reporting.TrainingRequirements.ListRowGenerator);

How do I get the actual object? The GetDataSource method is hidden by its access level.

 

 

 

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 18 Dec 2012, 10:14 AM
Hello Joe,

The Data Source Components are intended to specify declaratively how to retrieve data for Data Items but do not contain any data at all. Their purpose is only to specify the means how to obtain it (e.g. in the case of ObjectDataSource - by invoking a method/property of a custom business object, etc.). You can view the Data Source Components as wrapper for your data that can only read it and cannot modify it.

With that said, it would be best to access your objects directly, instead of involving ObjectDataSource. If your scenario requires it, please elaborate and we would advise you accordingly.

Kind regards,
Steve
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Joe
Top achievements
Rank 1
answered on 19 Dec 2012, 12:10 AM
I ended up doing this in the constructor:

 

 

_lrg = new ListRowGenerator(sqlDataSource1.ConnectionString);

Telerik.Reporting.ObjectDataSource objectDataSource = new Telerik.Reporting.ObjectDataSource();

objectDataSource.DataSource = _lrg.ListRows;

DataSource = objectDataSource;

where listrows is a generic list

List<ListRow> _listrows;

 

 

 

 

 

 

 

 

<ListRow> _listrows;

 


Tags
General Discussions
Asked by
Joe
Top achievements
Rank 1
Answers by
Steve
Telerik team
Joe
Top achievements
Rank 1
Share this question
or