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

Change query for chart in Telerik.Reporting in run time

1 Answer 240 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Covertix
Top achievements
Rank 1
Covertix asked on 01 Nov 2011, 12:38 PM
Hi,

I have a telerik report with chart.
The chart data source is a default sql query (I set it by design):

select *
from customers

In my ascx page I have a filter box, for example for the customer location with the values - All, France, Italy, Spain.
If the user selected location and pressed "Generate", I want to change the query to:

select *
from customers
where location = '(The selected value)'

if the selected value is all, I want to run the report as is.

Is there a way to change a chart query in run time?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 03 Nov 2011, 05:42 PM
Hello Tzach Kaufmann,

Do you utilize the SqlDataSource component? If this is the case you can modify the select command as shown in the following code snippet:

var report = new Report1();
var sqlDataSource = (Telerik.Reporting.SqlDataSource)report.DataSource;
if(....)
{
sqlDataSource.SelectCommand = select * from customers
where location = '(The selected value)';
}
this.ReportViewer1.Report = report;

Best wishes,
Peter
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

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