Solved

Reportviewer parameters not working

Posted on 2015-01-11
7
203 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
7 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 11

Expert Comment

by:srikanthreddyn143
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now