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

Data Source Access from Code Behind

2 Answers 342 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shane
Top achievements
Rank 1
Shane asked on 19 Jan 2017, 01:24 PM

Hello,

I am creating a report that pulls data from an SqlDataSource object. In the report's C# code-behind, I need to access the same data that the report uses to generate a string for an informational QR code on the report. Right now, I am pulling the data a second time from the same table through a data source for the project (DataSet object).

I'm wondering if there is a more efficient way to do this, as in a way to read the same data that the report has already selected. I've explored the SqlDataSource object's properties, but I'm pretty new to this and nothing seems to work there. Another solution could be to use an expression to pass all the values in a field from the report designer to a method in the code-behind, but I can't figure out how to do that either.

I'm not sure if this makes a difference, but in the report, the SqlDataSource is only used by a table and by the report parameters.

Let me know if more information is needed, and thanks in advance!

2 Answers, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 19 Jan 2017, 02:37 PM
Hello Shane,

Please check the How to use the ReportItem.DataObject property in expressions help article. It elaborates how to get the data associated with a processing element in an expression. This can be used for user functions as well.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Shane
Top achievements
Rank 1
answered on 23 Jan 2017, 01:11 PM

Hi Stef,

Thank you for the reply. This is what I needed.

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