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

Report parameters

4 Answers 275 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Maxime
Top achievements
Rank 1
Maxime asked on 12 Nov 2007, 08:59 AM

Hi,

1/ I tried to use the ReportParameters collection to pass paramaters to my report but I don't understand when the databinding occurs. I'seem to be directly after the report was created.

I saw on forum's samples that you combine report parameters with the Filters collection to filter results. But I already have a function of my Bussiness Layer that can take two date parameters to reduce data.

So I wan't to pass dates to the report and populating it with my function who take the two dates in parameters. How I can do that? At which place I must define the datasource property? Why isn't there a method Databind?

I tried to use the NeedDataSource event but I don't understand when it is fire.

2/ If the is no data to show, how I can replace the report struct by a simple message text ?

 Thanks for yours reponses.

4 Answers, 1 is accepted

Sort by
0
Maxime
Top achievements
Rank 1
answered on 14 Nov 2007, 07:47 AM
Hi,

Please, can somebody help me ?

Best regards,
0
sami
Top achievements
Rank 1
answered on 14 Nov 2007, 03:31 PM
hey Sébastien,
Before you initiate Report check if Data is present or not , 

sql="select * from emp"
if (ds!=null)
{
    ExportToPDF(reportnam, myinvoiceable);
}
else  "give your message"

check this and see where this will print your message.
0
Hrisi
Telerik team
answered on 14 Nov 2007, 04:02 PM
Hi Sébastien FLEURIET,

For your convenience we attached a project showing some aspects of Report databinding.

For demonstration purposes we created sample business object as a datasource.

If you do not have parameters the simplest way to bind the report is in design time to set DataSource.
In case you have parameters there are two approaches. One is to use NeddDataSource report event and in the handler you can use parameters to filter data and assign the result to the Telerik.Reporting.Processing.Report.DataSource property.
This technique can be read in our documentation Using Report Events. In the supplied code you can find the similar implementation but it is commented (not used).

Because values for the parameters can be provided by the user of the report we demonstrate how to filter the data and update Report definition. All this logic is implemented in the ReportViewer form. The Viewer is responsible to start the processing of the report by invoking RefreshReport().

Our reporting engine use the definition and DataSource to bind data to the report items, layout them and render the result to the output. In short, you can view that we does not use report parameters, because data are filtered outside the report.

In the same project we also show how to implement message showing "No Data" if the filter does not return any data.

I hope this information helps. Thank you.

Regards,
Hrisi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Maxime
Top achievements
Rank 1
answered on 14 Nov 2007, 07:10 PM
Thank you Hrisi,

I will look at that and I will test your sample project.

Best regards,
Tags
General Discussions
Asked by
Maxime
Top achievements
Rank 1
Answers by
Maxime
Top achievements
Rank 1
sami
Top achievements
Rank 1
Hrisi
Telerik team
Share this question
or