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

Silverlight NeedsDataSource not called for SaveAs PDF

1 Answer 51 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 10 Jul 2011, 05:39 PM
Hi,

Ive created a silverlight report that based on a parameter dynamically adds some report fields in code. So in my NeedsData event on the report definition I check a parameter and create some extra fields and then set the datasource for the report.

This seems to work fine to generate and print the report but when I use the silverlight reportviewer to save as pdf (or any save as format) then it appears I get a new instance of the report on the server (I can set a breakpoint in the constructor) but never get a needsdata event call. I tried moving my code to the constructor but it seems that my parameter is not not initialized yet in the constructor.

Where would be the correct place to dynamically add some report textblocks, etc. in code so that it works for both report generation and save as?

thanks,
Adam

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 11 Jul 2011, 05:19 PM
Hello Adam,

The NeedDataSource event is meant to be used only for providing data source to the report and that data source is cached unless changed i.e. once cached the NeedDataSource event is not fired again. As you probably know every time the report is previewed, paged or exported through the viewer it is processed and rendered from scratch. During this processing, the cached data source is used, but NeedDataSource is not fired second time. That is why any other changes should be moved to ItemDataBinding event which is fired regardless. 

All the best,
Peter
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
General Discussions
Asked by
Adam
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or