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

Binding to an ArrayList

1 Answer 229 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 13 Jan 2009, 03:51 PM
Hi

I'm new to Telerik Report perhaps you could help.

I've created a new report which binds to an object I created previously. The report runs OK but never produces any data. I have initialised the report as here: -

    Public Sub New(ByVal OnlineBookingData As ClassWebInterface.cwiOnlineBooking.OnlineBookingData)

        InitializeComponent()
        Me.DataSource = OnlineBookingData.SummaryItemList

    End Sub

OnlineBookingData.SummaryItemList is an arraylist of objects including fields I want to include in the report. I have confirmed that the SummaryItemList contains data but nothing show on the report.

Have I missed something?

Any help appreciated.

Regards,
Mike

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 14 Jan 2009, 01:19 PM
Hi Michael,

Looking at the code you've pasted, it seems that the problem is that your report does not have a default constructor (parameterless constructor). When you choose a datasource for the Report the IDE tries to generate the corresponding code for it - that is the code that resides in the InitializeComponent() method of your report classes. By default the serialization mechanism requires the classes to provide default constructor because it doesn't know what values to use for the constructor. Of course there are different ways to achieve this and use constructors with parameters, but this requires additional work and extensive knowledge of the code serialization.
For your scenario, you can:
  • leave the default constructor as is and use (if needed) properties to pass parameters to your report.
  • the Report.DataSource property is public which means you can access it (set it) from outside the report i.e. set it from the calling application TryCast(Me.ReportViewer1.Report, Report1).DataSource = OnlineBookingData.SummaryItemList
  • provide your own logic for passing the needed parameters

Best wishes,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Michael
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or