Solved

Reportviewer parameters not working

Posted on 2015-01-11
7
303 Views
Last Modified: 2015-01-13
I have a local report (.rdlc) file which has several textboxes that should be populated from report parameters

When I pass the parameters from my code behind and show the report, the default values are being displayed instead of the parameter values:

For example: A have a textbox with the expression: '=Parameters!THEDATE.Value' and a parameter called @THEDATE

The code to run the report is:

Dim rptLocal As New LocalReport
rptLocal.ReportPath = ("Reports\myReport.rdlc")

' Add the report parameters
Dim paramDate As New ReportParameter("THEDATE", txtDate.Text)
rptLocal.SetParameters(paramDate)
       
rptLocal.Refresh()

Open in new window

     

I get no errors, but only default text in the report textbox

Any help would be appreciated

thank you
0
Comment
Question by:BrianFord
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 40544414
Does the correct data appear for the parameters you entered or is it the data for the values being shown?

I am not that familiar with the RDLC tool but with Crystal the refresh sometimes deletes the parameters passed.  Try commenting out the refresh line

mlmcc
0
 

Author Comment

by:BrianFord
ID: 40544688
Thanks

I did try removing the Refresh but that didn't help, I'm pretty sure it's need for the rdlc, I have the same setup on other pages and it works fine
0
 

Author Comment

by:BrianFord
ID: 40544729
Sorry, I didn't fully answer your question.

Each parameter on the form has 'Default' value set, it is this value that is being displayed when the report renders and NOT the 'variable' value I am setting and applying in the code.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 40544875
Does txtDate.text has proper value?

Also check if the textbox in the report has any expression. If possible please post the report here.
0
 

Author Comment

by:BrianFord
ID: 40545497
Yes, the text box has a value, even if I hard coded a value like:
Dim paramDate As New ReportParameter("THEDATE", "My text here") it still doesn't work

The textbox on the report does have an expression: =Parameters!THEDATE.Value'
0
 
LVL 37

Accepted Solution

by:
ValentinoV earned 500 total points
ID: 40546095
I think the problem is that you're creating a new LocalReport instead of referring to the one that's bound to the ReportViewer.  The SetParameters line should go something like this:

Me.YourReportViewer.LocalReport.SetParameters(New ReportParameter() {paramDate})

Open in new window

0
 

Author Closing Comment

by:BrianFord
ID: 40546416
That worked!!

The strange thing here is that I have another page with code identical to this (except it's looking at a different report) and that works perfectly.

But hey, this fixed it so thank you very much
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question