Pass multiple parameters to report viewer control (asp.net)

Hi

I've got this link and it works fine with singe parameters http://technet.microsoft.com/en-us/library/aa337091.aspx

I'm trying to pass multiple parameters and most of them are multi-select drop down boxes. Is there a way to make it work like that?

Many thanks in advance
Emil
LVL 10
itcoupleAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Megan BrooksSQL Server ConsultantCommented:
Are you using the ReportParameter class to create report parameters? The contructor has several overloads. For a multi-select parameter, use an overload that takes a string array instead of a single string.
itcoupleAuthor Commented:
Hi Megan

I got lost a little bit with this. As far as I know my colleage i(not myself) is using the link which I found using google :) but has difficulties with multiple parameters (I think one multi-select value parameter worked but I would have to double check that)..... How do we need to modify it to pass let say values from several drop down boxes?

Many thanks in advance
Emil
Megan BrooksSQL Server ConsultantCommented:
I am not sure yet what you are trying to do. The link you provided me above was about API-level programming information on passing parameters into the WebForms ReportViewer control, so that is what I responded to.
How are you passing parameters? It could be through the ASP.NET API, or via URL Access, or possibly something else that I haven't thought of. I need to know a little more about what you are doing.
If you are displaying reports by accessing the ReportServer URL, you can pass URL Access report parameters. Just add the report parameters to the the URL as query parameters. The basic syntax is described here:
http://msdn.microsoft.com/en-us/library/ms155391.aspx
Since you have multi-valued parameters you may need to repeat some of them. If I remember correctly, you simply include "&parametername=xxx" more than once in the URL, where "parametername" remains the same and "xxx" changes,
http://hostname/reportserver/Pages/ReportViewer.aspx?/reportpath¶m1=a¶m1=b¶m1=c 
In other words, you can repeat a mult-valued query parameter as necessary.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

itcoupleAuthor Commented:
Hi

I personally don't know what I'm doing :) so my comments might not make any sense but your reply I think provides the answer I needed.

Many thanks!
itcoupleAuthor Commented:
I've just tried link with multi-select and it worked! Thanks
itcoupleAuthor Commented:
One more question.... I've tried it and tested max size and it seems it accepted maximum 2047 characters. I hope that won't cause me any issues? I presume I  can always shorten parameter name :)
Megan BrooksSQL Server ConsultantCommented:
There can definitely be a limit on URL length, and it can depend upon both the web server and the browser. If you are going to be sending a lot of values, you should consider a different way of doing it.
As long as you use URL Access and the built-in ReportViewer in ReportServer, you will have this limitation. If, however, you create your own web page containing a Visual Studio ReportViewer control, you can pass as many parameters as you like. There is a greatly improved ReportViewer in Visual Studio 2010 that overcomes limitations of the earlier ones. I just migrated to it yesterday.
By the way, if you are using URL Access parameters, you can add as many different parameters as you need to the URL, as well as multiple values of the same parameter (in the case of mult-valued parameters).
If you are passing ReportParameter objects to the ReportViewer control (as in your original TechNet link), the ReportViewer.SetParameters method argument is an array of ReportParameters. The example in the TechNet article passed a single-element array, but you can create a longer one.  Their example reads
localReport.SetParameters(new ReportParameter[] { rpSalesOrderNumber });
but in general the pattern is:

localReport.SetParameters(new ReportParameter[] { rpFirst, rpSecond, rpThird, ... });  
where each item in the parameter list is a ReportParameter object. The list inside the braces supplies the values for the array being created.
itcoupleAuthor Commented:
Many thanks

We will possibly got with URL for the time being as it should work and for new projects look into reportviewer as an alternative... I hope they will upgrade us to 2010 soon.... but they upgraded us recently to 2008 so that might not be so soon :p
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
SSRS

From novice to tech pro — start learning today.