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

Report Parameter Issues

3 Answers 360 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Karin
Top achievements
Rank 1
Karin asked on 29 Jul 2008, 01:57 AM
Hi,

I'm having some difficulty with the Report Parameters. I've been following previous posts and reviewing examples (in particular the WebReportParams) however my parameters are reset back to their default when the report is run. From my debugging it looks like the default constructor is being called when the report is processing which is overwriting the parameter values I previously set.

Here's some of my code to give you and idea of what I'm doing.

ASPX Page - in a button.click handler

Dim report As New BizportReports.PreBill(rcb_BillNo.SelectedValue)
report.ReportParameters(0).Value =
"New Text"
Me.ReportViewer1.Report = report


Report Code - two constructors

Public

Sub New()
InitializeComponent()
Try
Me.DataSetTableAdapter1.Fill(Me.DataSet1.vTable)
Catch ex As System.Exception
System.Diagnostics.Debug.WriteLine(ex.Message)
End Try
End Sub


Public
Sub New(ByVal p_BillID As Int16)
InitializeComponent()
Try
Me.DataSetTableAdapter1.FillWithParameters(Me.DataSet1.vTable, p_BillID)
Catch ex As System.Exception
System.Diagnostics.Debug.WriteLine(ex.Message)
End Try
End Sub

Lastly report parameter is accessed through;

Me

.Report.ReportParameters(0).Value

I tried removing the second constructor to make the BillID a Report Parameter as well, however the same issue occurred and the BillID was always reset.

Any ideas?
Cheers,
Karin

3 Answers, 1 is accepted

Sort by
0
Milen | Product Manager @DX
Telerik team
answered on 29 Jul 2008, 11:45 AM
Hello Karin,

By the fact that you are accessing the value of the parameter programmatically I can conclude that you actually do not need to use a report parameter. Report parameters are designed to be used in expressions like in the Filters or ConditionalFormatting and/or you need the automatic UI the report parameters are providing, allowing interactivity in your reports. Please review the help article Report Parameters for more information.

In your case (when you do not use these features) as in any other .NET class you can add a public property in your report and use it to transfer data as needed. You will find very useful this training movie.  

If you still need to use the report parameters, please specify where are you trying to access the value of the parameter? Or even better send us a sample report demonstrating the issue you are facing.

Best wishes,
Milen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Karin
Top achievements
Rank 1
answered on 31 Jul 2008, 01:41 AM
Thank you, however I'd already reviewed the documentation and the training videos before posting. I couldn't find an example of what I was trying to do but I also didn't find anything obvisously wrong with my code.

I have one parameter that is used as a sql parameter in the query which works fine. I also need other parameters to provide additional customisation of the report. For instance an Invoice seed number so that I can increment the seed number based on the report items. I also need another parameter to determine whether to hide sections of the report.

The basic issue is that the ReportParameters and any other report variables never retain the values that I set when the report is processed. This appears to be because the default contructor is called after my custom constructor and it creates new objects. It's like there are two report objects being created. One by me when the ReportViewer is assigned a report object and another when the ReportViewer starts to process the report.

Any suggestions of what I could look into?
Cheers,
Karin
0
Milen | Product Manager @DX
Telerik team
answered on 01 Aug 2008, 01:07 PM
Hello Karin,

Indeed, there is a report instance created during the processing of the report and it is of type Telerik.Reporting.Processing.Report . More about it you can learn in the help article Report Life Cycle. The processing instance of the report is the bind to data and evaluated version of the report definition (Telerik.Reporting.Report).

However, this should not prevent the ReportParameters to be usable. Find attached a sample solution with a report showing different usages of the report parameters. Also you will find a windows application demonstrating passing of values to the report parameters, and the automatic UI of the parameters.

Please write us if you need further assistance.

Kind regards,
Milen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Karin
Top achievements
Rank 1
Answers by
Milen | Product Manager @DX
Telerik team
Karin
Top achievements
Rank 1
Share this question
or