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

Empty Report after bind DataSource

4 Answers 512 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
intrasoft
Top achievements
Rank 1
intrasoft asked on 17 Dec 2008, 02:32 PM
Hello,

I'm a absolutley newbie in Telerik-Reports and need your help :-). I created a new Report with a new BusinessObjects, createt Textboxes with the Wizard (labelsGroupHeader, textboxes in the detail-area).

I try to create the Report as follow:
- Load my Business-Object
- Create a Report-Object (with the Business-Object oDT)
- Then I bind the Object as Datasource

        public Report_SAP(object oDT)
        {
            InitializeComponent();
            this.DataSource = oDT;
        }

-Then I show the Report in a Viewer:
ReportViewer.Report = oReport;

But, as soon I have Data in my Business-Object (its a typed DataTable) the report is empty (blank page). When the BO is empty, the page is not empty (footer is shown).

Can somebody help me??

Thx
Bruno



4 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 17 Dec 2008, 03:15 PM
Hello Bruno,

You can find how our Reporting serializes your Business object by looking in the Designer generated code. During processing stage of the report, your DataSource is instantiated by invoking  Activator.CreateInstance((Type)YourBusinessObject). If your BusinessObject does not contain data initialization in its default constructor, no data will be supplied to the report.

In order to fill your BusinessObject with data you can write something like this in the constructor of the report:

Class YouReport: Report
{
    public YouReport()
    {
        InitializeComponent();
       
        YourBusinessObject bo = new YourBusinessObject();
        <fill the bo with data>
        this.DataSource = bo;
    }
}


You can find in our examples how we use Bussiness objects to provide data to the ListBoundReport report.

or review this forum thread that elaborates on the functionality with a sample report as well.

Best wishes,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
intrasoft
Top achievements
Rank 1
answered on 18 Dec 2008, 07:11 AM
Hello Steve,

thanks for reply. But I don't understand what you mean :-).

I think I do the things you describe, don't I?
My BO is a DataTable (a typed one), it will be loaded with Data outside of the Report, I modified the Report-Constructor with a DataTable Parameter.
        public Report_SAP(object oDT)
        {
            InitializeComponent();
            this.DataSource = oDT;
        }


The Textboxes in the Report are bound to the Fields [=Fields.PSP_ELEMENT].
Theres a Titel-Label on the Report as well. As soon theres Data in the DataTable-BO the Report is empty. If the BO is empty, the Label will be shown. I think I have a generell problem, but I don't know whats the problem...

Here the Code-Snippet:
(Business-Logic)
     ReportDataSet.SAPExportDataTable oDT = null;
     if (mDataAccessHigh.GetReportData(nID, ref oDT))
                {
                    Reports.ReportData oReportDetail = new iReportData(oDT);
                    oReport = oReportDetail;
                    bRet = true;
                }

(the Object oReport will bind to the ReportViewer)

(Report-Code)
    public partial class GetReportData : Telerik.Reporting.Report
    {
        public GetReportData(object oDT)
        {
            /// <summary>
            /// Required for telerik Reporting designer support
            /// </summary>
            InitializeComponent();
            
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            this.DataSource = oDT;
            
        }
    }

I really hope you can help me, thx

Bruno




0
Shahid Saeed
Top achievements
Rank 1
answered on 18 Dec 2008, 07:37 AM
Hi Steve,
I'm having the same problem... I followed the following steps to implement a report in Asp.net:

1. Added a Telerik Report (thru new Item). It also added required code in the App_Data
2. I right clicked on the Report and viewed its designer, which displayed it, and then I tried to add the Data Source at design time. There was no data source at the first time. I also added a new connection named "cargoDataSet" which also lets me previewing data
3. But as soon as I try to select "cargoDataSet" it doesn't do it. Therefore, I did it thru code (as described in some another post by you) as follows in the Report's constructor:

 

public EstimationReport()

 

{

 

  InitializeComponent();

 

 

  this.DataSource = new cargoDataSet();
}
4. Then I added a new Web Form and dropped the Telerik Report Viewer, and set the Report property as "EstimationReport"
5. I tried to view the report in the Browser, but it is not showing the data !!! although the data set is letting me preview data. It is just showing me the skeleton of the Telerik Report with Unbound fields.

Kindly help me to resolve this issue, as I'm getting frustrated :D

Thanks a lot

Shahid

 

0
intrasoft
Top achievements
Rank 1
answered on 18 Dec 2008, 02:40 PM
I solved my problem...

If you use a DataSet you have to set DateMember, if you use a DataTable you can set Report.DataSource=oDataTable.DefaultView

Cheers
Bruno
Tags
General Discussions
Asked by
intrasoft
Top achievements
Rank 1
Answers by
Steve
Telerik team
intrasoft
Top achievements
Rank 1
Shahid Saeed
Top achievements
Rank 1
Share this question
or