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

Using NeedDataSource

2 Answers 101 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Don
Top achievements
Rank 1
Don asked on 13 Mar 2013, 04:40 AM
I've created a report that has a business object as its data source. For a number of tables I select lists within the object and use it to layout the report. What i noticed is that for each table the constructor of the business object is called each time.

What I would like to do is initialize the object outside the report and then use NeedDataSource to pass the appropriate data in (looking at the data member in sender object?) to pass in the appropriate data.

NeedDatasource is not firing and I read that it will not be if the report has a datasource. So now I am not passing in the data source but the report is still instantiating its own I suppose because when defining the data source in the designer enables the report to create its own. I theorize that if I create the report this way and then unhook the tables from data sources that needdatasource will be fired but this seems like an odd way to do things.

I am obviously missing something, any pointers would be greatly appreciated.

Thanks,
Don Rule
Translational Software

2 Answers, 1 is accepted

Sort by
0
Squall
Top achievements
Rank 1
answered on 15 Mar 2013, 08:12 AM
Hi,
Every table have a private NeedDataSource and you have to attach your handler to the table's NeedDataSource event:
this.table1+=myNeedDataSourceHandler
 
void myNeedDataSourceHandler(object sender, EventArgs e)
{
 
}

0
Don
Top achievements
Rank 1
answered on 16 Mar 2013, 01:41 AM
I don't really want to modify every report with NeedData for every table. I need to be able to hook events from the report generator, look at what data it is requesting and then supply that data based on an instance of the class that I have initialized. I am catching ItemDataBinding now and passing in the right data back but the reporting engine is still creating a new object for each table.

Thanks,
Don Rule

Tags
General Discussions
Asked by
Don
Top achievements
Rank 1
Answers by
Squall
Top achievements
Rank 1
Don
Top achievements
Rank 1
Share this question
or