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

Working with Objectdatasource

1 Answer 168 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Koen L
Top achievements
Rank 1
Koen L asked on 25 May 2010, 03:02 PM
Hello,

I'm new here and testing the report tool.

I am trying to create a template (report) for our orders to suppliers.
I like to pass my Order object as datasource what works fine. So i can put info in the report about my supplier (name,address,...)
about my company (name, phone,....). Those two are subobjects of Order (Supplier and Company). So i can access fields from those subobjects of Order.

Now the problem starts with my OrderLines when Order is my datasource i can't use my object orderline that is in the collection OrderLines (this OrderLinesCollection is an object of Order). The expression would look like this =Fields.OrderSupplierLineCollection.Item.Product.Family. Seems i can't reach item in a collection?
Error i get after using the tablewizard : 
An error has occured while processing TextBox 'textBox19':
Common Language Runtime detected an invalid program.
I tryed to do this with a tablewizard and a subreport. (did not find an example that covers this)

So we want a total dynamic orderreport. Company,supplier,lines is all dynamic.
In the header we put the contactinfo of our company and the supplier. In the detail of the report we would like to see our orderlines.
This all with just one Order object that contains all the info.

Is this possible? Where am i going wrong?
Kind Regards,

1 Answer, 1 is accepted

Sort by
0
Koen L
Top achievements
Rank 1
answered on 26 May 2010, 09:13 AM
Found my solution.

I worked out the master-detail system. (subrapport)
The master gets my Order object where i can use the company,supplier fields.
Then i pass my orderlinecollection with needdatasource event.

private

 

void subReport1_NeedDataSource(object sender, EventArgs e)

 

{

    Telerik.Reporting.Processing.

SubReport subReport = (Telerik.Reporting.Processing.SubReport)sender;

 

    ObjectModel.Order.

OrderSupplier orderSupplier = (ObjectModel.Order.OrderSupplier)subReport.DataObject.RawData;

 

    subReport.InnerReport.DataSource = orderSupplier.OrderSupplierLineCollection;

}


subReport.DataObject.RawData <-  Contains my Ordersupplier object that i passed as datasource on creating a new rapport.

Hope this can help someone :).

Kind Regards,

Tags
General Discussions
Asked by
Koen L
Top achievements
Rank 1
Answers by
Koen L
Top achievements
Rank 1
Share this question
or