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

Report Data Not Displaying When populating the Data From DataSet

4 Answers 966 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sudhakar
Top achievements
Rank 1
Sudhakar asked on 18 Feb 2013, 10:53 AM
Hi,

I am trying to pass the Data from C# to Telerik Report. Initially i created a Web Project and I added Telerik Report to the Project. I followed a tutorial to create a Report and assign a Dataset to the Report. Here i will be designing a Report. I need to assign a Data To Report through a Datatable, which need to be populated in Report where we need to Map The Columns. On Page Load i am Trying to do this,

In My Page Load i written by Code as

   Report2 objReport2 = new Report2();
                objReport2.DataSource = GetAllData();
                ReportViewer1.ReportSource = objReport2;
                ReportViewer1.DataBind();
                ReportViewer1.RefreshReport();

From the above code, i am seeing the blank Report wihtout Data.
In Desinger i created a table, But i failed to create  a Mapping between Report And Dataset Column? May i know how do i do this? Or else can any one suggest me a scenario to resolve this?   
Please find the Sample Project Link http://www.mediafire.com/?9hd3apr88j6m17x

4 Answers, 1 is accepted

Sort by
0
Sudhakar
Top achievements
Rank 1
answered on 18 Feb 2013, 11:08 AM
Hi Team, Any Idea On this...
0
Steve
Telerik team
answered on 19 Feb 2013, 10:17 AM
Hello Sudhakar,

The code you've provided is not correct and should be modified as follows:

Report2 objReport2 = new Report2();
Telerik.Reporting.Table tableItem = objReport2.Items.Find("table1", true)[0] as Telerik.Reporting.Table;
Telerik.Reporting.ObjectDataSource obds = (Telerik.Reporting.ObjectDataSource)tableItem.DataSource;
obds.DataSource = GetAllData();
obds.DataMember = "Product";
Telerik.Reporting.InstanceReportSource irs = new Telerik.Reporting.InstanceReportSource();
irs.ReportDocument = objReport2;
ReportViewer1.ReportSource = irs;
ReportViewer1.RefreshReport();

Please note a few important things:
  • the Table item is a separate Data Item that has its own data source, so you should find the data item in question and get the DataSource from it.
  • a single data item can be bound to a single data source and a data source can be bound to a single datatable. Since your query returns 3 tables, you should use the DataMember property of the data source component to specify which DataTable to bind to.
  • the ReportSource property of the viewer expects a reportsource type, not report.

In general whenever your data comes from a database server, it is recommended to use the SqlDataSource Component as datasource instead. I have attached your modified working project, you can see Report1 which binds directly via the SqlDataSource component.

All the best,
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
kenneyy kenn
Top achievements
Rank 1
answered on 27 Feb 2013, 12:15 PM

 

 

0
Frederic
Top achievements
Rank 1
Iron
answered on 21 Nov 2023, 01:19 PM

This saved my day!

I found a small tweak.

First change the modifier of the objectdatasource1 in the report from private to public.

 

            this.R1 = new Report1();
            this.R1.objectDataSource1.DataSource = this.GetAllData();

            this.RS = new Telerik.Reporting.InstanceReportSource
            {
                ReportDocument = this.R1
            };

            this.reportViewer1.ReportSource = this.RS;

            this.reportViewer1.RefreshReport();
Tags
General Discussions
Asked by
Sudhakar
Top achievements
Rank 1
Answers by
Sudhakar
Top achievements
Rank 1
Steve
Telerik team
kenneyy kenn
Top achievements
Rank 1
Frederic
Top achievements
Rank 1
Iron
Share this question
or