Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1784
  • Last Modified:

Pass ReportViewer Parameter as Report Title

I would like to pass a parameter to a ReportViewer to use in the Page Heater.

I have the code:
Dim params As ReportParameter() = New ReportParameter(0) {}
params(0) = New ReportParameter("userOptions", "xxx")
ReportViewer1.LocalReport.SetParameters(params)

I have the parameter userOptions set in the Report Parameters dialog as a string data type.

And I have a text box in the Page Header whose Value is set to:
=Parameters!userOptions

Without this parameter the report runs just fine, but with it, I get the error LocalProcessingException, "An error occurred during local report processing," on the third line of code shown above.

Could there be something I'm not filling out in the dialog?  Or what do I have wrong?
0
Amy
Asked:
Amy
  • 8
  • 7
1 Solution
 
pdd1lanCommented:
try to put put "Me.ReportViewer1.RefreshReport()"

Dim params As ReportParameter() = New ReportParameter(0) {}
params(0) = New ReportParameter("userOptions", "xxx")
ReportViewer1.LocalReport.SetParameters(params)
Me.ReportViewer1.RefreshReport()
0
 
AmyAuthor Commented:
Yes, I have RefreshReport.  But the error comes on the SetParameters line.
0
 
pdd1lanCommented:
I copied your code, set textbox in page head =Parameters!userOptions.Value
and run it and it worked for me

 Dim params As ReportParameter() = New ReportParameter(0) {}
        params(0) = New ReportParameter("userOptions", "xxx")
        ReportViewer1.LocalReport.SetParameters(params)
        Me.ReportViewer1.RefreshReport()
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
AmyAuthor Commented:
So it must be something in my report.  My report runs just fine without that line where it uses the parameters.
0
 
pdd1lanCommented:
have you tried to create a new RDLC report instead?  something might helps.
0
 
AmyAuthor Commented:
I tried creating another report and using that one.  Now I get the message that the "parameter is missing a value."

Could it be that I'm setting things wrong in the Report Parameters dialog?
0
 
AmyAuthor Commented:
Now I've tried checked the box in the Report Parameters to allow null values, and I get the message, "Some parameters or credentials have not been specified."
0
 
pdd1lanCommented:
in the report, have you created a Parameters (userOptions)?

can you attach your report (rdlc) file?  I give it a look if you would like....
0
 
AmyAuthor Commented:
Yes, I have created the parameter userOptions.

Here is my rdlc file.
TasksToDo.rdlc.txt
0
 
pdd1lanCommented:
try it:

delete your "userOptions" parameter in your report, remove =Parameters!userOptions.Value in textbox8

recreate "userOptions" parameter in your report, and reset "=Parameters!userOptions.Value" in your textbox 8.  and should fix your issue.

also, your textbox8 was set in visible= false (hide mode), you need to set it to visible = true (visibillity to show).



0
 
AmyAuthor Commented:
Now I get "The 'userOptions' parameter is missing a value" instead of the report showing in the ReportViewer when I run it.

Is there something I need to set in the parameters?
0
 
pdd1lanCommented:
look like your report parameter does not check for "Allow blank value" or "allow null value" property.
if you don't check them in your "userOptions" report parameter, and then when you pass a null or empty value into your report, it will give you "parameter is missing a value" error.

------
Dim params As ReportParameter() = New ReportParameter(0) {}
        params(0) = New ReportParameter("userOptions", "xxx")
        ReportViewer1.LocalReport.SetParameters(params)
        Me.ReportViewer1.RefreshReport()
0
 
AmyAuthor Commented:
Thank you, pdd1lan.

I copied your code exactly, and I checked the box to allow for Null values.

Now where the report should show in the ReportViewer when I run it, it says "Some parameters or credentials have not been specified."
0
 
AmyAuthor Commented:
Success!  Yea!

I needed both refreshes:
ReportViewer1.LocalReport.Refresh()
ReportViewer1.RefreshReport()
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now