Solved

Reportviewer parameters not working

Posted on 2015-01-11
7
255 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
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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
Introduction In the following article I’ll be discussing and demonstrating several different ways of how images can be put on a report. I’m using SQL Server Reporting Services 2008 R2 CTP, more precisely version 10.50.1352.12, but the methods ex…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

792 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