How to pass multi value parameter to SSRS from asp.net c#?

半腔热情 提交于 2020-01-01 19:47:09

问题


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.

here is the method I am using:

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.


回答1:


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);


来源:https://stackoverflow.com/questions/18002218/how-to-pass-multi-value-parameter-to-ssrs-from-asp-net-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!