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

Report Book & Parameters

2 Answers 337 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
TPerry
Top achievements
Rank 1
TPerry asked on 18 May 2009, 01:23 PM
I am trying to create a Report Book by programmatically adding Reports to it.  In the Report New() sub, I need to access a parameter.  When I just display one report at a time, I set a Session variable and then access that Session variable in the New() Sub which works great.  But, since I want multiple Reports, it runs through the New() sub each time fine, grabbing the Session variable correctly, but then it runs through them all again, and that time, it only grabs the last Session variable, therefore, the data in each Report is incorrect.

Here's my code (with hard code values for testing of course):

In my aspx.vb page:

BNID =

"1270"

 

System.Web.HttpContext.Current.Session(

"BNID") = BNID

 

 

Dim Report As Telerik.Reporting.Report

 

Report =

New DataEntryScreen

 

Report.ReportParameters(0).Value = BNID

 reportBook.Reports.Add(Report)

 

BNID =

"1271"

 

System.Web.HttpContext.Current.Session(

"BNID") = BNID

 

 

Dim Report2 As Telerik.Reporting.Report

 

Report2 =

New DataEntryScreen

 

Report2.ReportParameters(0).Value = BNID

System.Web.HttpContext.Current.Session(

"BNID") = BNID

 

reportBook.Reports.Add(Report2)

ReportViewer1.Report = reportBook

In my DataEntryScreen.vb page:

 

Public

 

Sub New()

 

InitializeComponent()

 

'Grab the BNID to use

 

 

 

Dim BNID As String = System.Web.HttpContext.Current.Session("BNID")

 

 

'Populate the Parameters

 

 

 

Me.DataEntryDetailsReport1.ReportParameters(0).Value = BNID.ToString

 

 

End Sub

 

 

 


Any help?

 

 

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 19 May 2009, 03:11 PM
Hello TPerry,

Setting report parameters in the report constructor is not a very good idea and looking at your code I cannot figure out the purpose of adding the value in the session variable and then assign it to the report parameter, when you can simply set the parameter's value in the aspx page like so:

   Dim report1 As New Report1()
   report1.ReportParameters("MyParam").Value = "your_value"

If this does not work for you, please explain what you're trying to achieve and we would be able to provide you with more to the point answer.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Syed
Top achievements
Rank 1
answered on 25 May 2009, 12:26 PM
Hi,

I too have the same problem.

I am passing a value from my aspx page to the report parameter. I keep reportviewer on the same page.

I have a value in the textbox "employee_id"  and want to pass this as parameter to the report.

Example.

 Me.report.ReportParameters("MyParam").Value = employee_id

Thanks.

Regards
Syed Arshad
Tags
General Discussions
Asked by
TPerry
Top achievements
Rank 1
Answers by
Steve
Telerik team
Syed
Top achievements
Rank 1
Share this question
or