本文介绍了如何从asp.net c#将多值参数传递给SSRS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在连接带有嵌入式ReportViewer控件的网站.我需要将多值参数(字符串数据类型)传递给报表.我尝试使用以下方法,但是每次带参数的报告错误都缺少一个值.

I am hooking up a site with an embeded ReportViewer control. I need to pass a Multi-value parameter (string data type) to the report. I have tried using the following methods but each time the report errors with a parameter is missing a value.

这是我使用的方法:

string s = String.Join(",", paramValue.ToArray());
// method 2 carriage return new line delimited string

string s = String.Join("/r/n", paramValue.ToArray()) + "/r/n";
// method 3 values as a string array

string[] s = paramValue.ToArray();
paramList.Add(new ReportParameter("ParamName", s, false));

显然,上面的代码与我使用的代码不完全相同,但是确实显示了我尝试过的变体.

Obviously the above code is not exactly what I am using but it does show the variations I have tried.

以上所有方法均无效.请帮助我解决这个问题.

None of the above works. please help me with this problem.

推荐答案

您必须将其作为数组添加到类型为 StringCollection Values 属性中.

You have to add it as an Array to the Values property of type StringCollection .

 List<ReportParameter> rptParams = new List<ReportParameter>();
    ReportParameter param = new ReportParameter("ParamName");

    string[] values = new string[]{"a", "b", "c"};

    param.Values.AddRange(values);

    rptParams.Add(param);

    this.ReportViewer1.ServerReport.SetParameters(rptParams);

这篇关于如何从asp.net c#将多值参数传递给SSRS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 12:22