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

Set CrossTab DataSource in code-behind

3 Answers 470 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Marcello
Top achievements
Rank 1
Iron
Marcello asked on 04 Nov 2014, 03:13 PM
Hi,

I develop my reports with a standard sql connection.
Contrariwise, when I consume the reports in my application I set datasource programmatically (report.DataSource=<DataTable>).
All work good if the report is a simple report.
If it contains a CrossTab the ReportViewer fails and show a message as "An error has occurred while processing Table 'crosstab1': Unable to establesh a connection to the database..."

Thanks,
marc.

3 Answers, 1 is accepted

Sort by
0
Marcello
Top achievements
Rank 1
Iron
answered on 06 Nov 2014, 09:40 AM
No suggestions...?
marc.
0
Stef
Telerik team
answered on 06 Nov 2014, 05:19 PM
Hi Marc,

The Crosstab item is a data item, having its own DataSource property. to set its DataSource at run-time you can access the item from the report's Items collection as follows:
var report=new MyReport();
var crosstab= report.Items.Find("crosstab1",true)[0] as Telerik.Reporting.Crosstab;
 
report.DataSource=GetReportData();
crosstab.DataSource=GetCrosstabData();
 
reportViewer1.ReportSource = new InstanceReportSource { ReportDocument = report};

I hope the above information is helpful.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Aseman
Top achievements
Rank 1
Veteran
answered on 29 Jun 2020, 06:27 PM
your solution has more than 1 connection string 
Tags
General Discussions
Asked by
Marcello
Top achievements
Rank 1
Iron
Answers by
Marcello
Top achievements
Rank 1
Iron
Stef
Telerik team
Aseman
Top achievements
Rank 1
Veteran
Share this question
or