Solved

Reportviewer parameters not working

Posted on 2015-01-11
7
233 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Where did System.Data.Objects go? 2 27
VB.Net/LINQ: ".Contains" condition not finding existing result in MSSQL 16 35
ASP/VB email question 4 34
No Data for DropDown List 2 24
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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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