0

I am trying to pass multiple value in query string in my ASP.Net web report in VS2012. The page has to pass multiple values to the report as a parameter . When I sent a single value (for eg: abc,) the data is being pulled up correctly but however when I am passing multiple values separated by a comma (eg abc,xyz) it is not displaying the results These multiple values separated by a comma are being passed to the page as query strings and we then are reading them and passing it to the report.

Please note: For the parameter in the report, I set the default list of values and I also defined available set of values. Now when I am trying to trying pass the values to this parameter from c# code, it is still not accepting the values that I supplied instead it is taking all the values from available list. I think the problem is that the SSRS is not accepting values separated by a comma when "Allow multiple values" check box is checked. Please advise.

This is what I am trying so far:

ReportParameter pb1 = new ReportParameter();
    if (!string.IsNullOrEmpty(Request.QueryString["pm1"])) { 
        pb1.Name = "PurchaseMaterial1";
        string[] strPb1 = Server.UrlDecode(Request.QueryString["pm1"]).Split(',');
        string value = Server.UrlDecode(Request.QueryString["pm1"]);
        if (strPb1.Length > 0)
        {
            int i = 0;
            value = "";
            while (i < strPb1.Length)
            {
                if (value == string.Empty)
                {
                    value = "'" + strPb1[i] + "'";
                }
                else
                {
                    value += ",'" + strPb1[i] + "'";
                }
                i += 1;
            }
        }
        pb1.Values.Clear();
        pb1.Values.Add(value);

An alternative to using a comma delimited parameter is reusing the same parameter like: www.test.com/?pm1=test1&pm1=test2&pm1=test3. But this approach is not acceptable by the business and would like to have ability to separate values by coma itself.

Please help, thanks much in advance :)

Joy1979
  • 599
  • 5
  • 12
  • 23
  • Is there any reason in particular you're not using the [previous question](http://stackoverflow.com/questions/26552587/unable-to-pass-multiple-values-in-querystring-in-aspx-to-report-at-runtime) you asked on this topic? – mason Oct 27 '14 at 18:06
  • Unfortunately no luck with any of the solution offered so trying to rephrase my question with more details. – Joy1979 Oct 27 '14 at 18:16
  • Then you should edit the question rather then creating a new one. – mason Oct 27 '14 at 18:18
  • Do you have any solution? – Joy1979 Oct 27 '14 at 18:19
  • I personally do not have a solution. But that's irrelevant. You should use your original question, adding detail or clarifying it as appropriate. Make sure you also respond to the comments, as those looked promising. – mason Oct 27 '14 at 18:20
  • Sure...I'll make sure. Thanks – Joy1979 Oct 27 '14 at 18:22

1 Answers1

0

A ReportParameter object takes a string collection as a value. So what you want is something like this (I speak VB, so please accept my apologies and translate accordingly):

string qryParams() = split(queryString, ",");

for each qryParam in qryParams
    pb1.values.add(qryParam);
next

What you were doing was adding one parameter with commas in it and not adding multiple params.

Duston
  • 1,601
  • 5
  • 13
  • 24