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

Access the Fields of ObjectDataSource in either OnItemDataBound or OnItemDataBinding

1 Answer 140 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael Kniskern
Top achievements
Rank 1
Michael Kniskern asked on 04 Oct 2012, 05:09 PM
I want to programmatically access the fields collection in the ObjectDataSource object in either the OnItemDataBound or OnItemDataBinding event of the Telerik report to hide report elements if they do not contain values.

How would I accomplish this in the code file of the Telerik report?

1 Answer, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 09 Oct 2012, 09:03 AM
Hello Michael,

You cannot manually read the data from the ObjectDataSource itself but you can access the data objects of the processing items. For example you are listening for a Report_ItemDataBinding event:
private void Report8_ItemDataBinding(object sender, EventArgs e)
{
    var procRep = sender as Telerik.Reporting.Processing.Report;
    var data = procRep.DataObject;
}
data will be the data which is bound to the report (which is your actual data-source).
If you listen to DetailSection_ItemDataBinding, then the DataObject will  be just one row from the data-source. 

It is not always needed to use event to hide items conditionally. If you explain in further detail what exactly is your scenario, we might give you an easier solution.
 
Regards,
Elian
the Telerik team

HAPPY WITH TELERIK 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!

Tags
General Discussions
Asked by
Michael Kniskern
Top achievements
Rank 1
Answers by
Elian
Telerik team
Share this question
or