Hello Friends..
This should be simple process but now it became annoying issue.
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(); try { string[] multiple; string value = ""; if (!string.IsNullOrEmpty(Request.QueryString["pb1"])) { pb1.Name = "ProductBusiness1"; string[] strPb1 = Server.UrlDecode(Request.QueryString["pb1"]).Split(','); value = Server.UrlDecode(Request.QueryString["pb1"]); 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; } } multiple = new string[] { value }; //pb1.Values.Clear(); //pb1.Values.Add(value); //string[] values = new string[] { Server.UrlDecode(Request.QueryString["pb1"]).ToString() }; //pb1.Values.AddRange(values); //rptParams.Add(pb1); pb1.Values.AddRange(multiple); //Response.Write(value); } ReportParameter pb2 = new ReportParameter(); if (!string.IsNullOrEmpty(Request.QueryString["pb2"])) { pb2.Name = "ProductBusiness2"; pb2.Values.Add(Server.UrlDecode(Request.QueryString["pb2"])); } //hiddenResetCache ReportParameter vt = new ReportParameter(); vt.Name = "ViewType"; string val = string.Empty; if (hiddenResetCache.Text == "1") { hiddenResetCache.Text = "0"; val = returnCacheValue(true); } else { val = returnCacheValue(false); } vt.Values.Add(val); ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { plant }); if (!string.IsNullOrEmpty(pb1.Name)) { ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { pb1 }); } if (!string.IsNullOrEmpty(pb2.Name)) { ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { pb2 }); } ReportViewer1.ServerReport.SetParameters(new ReportParameter[] { vt }); } catch (Exception ex)
I am aware that 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