Solved

Reportviewer parameters not working

Posted on 2015-01-11
7
267 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 100

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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installati…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

749 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