Report Server multiple value 多值选择

一、项目需求                                                                                            

  今天在做项目的时候,有一个需求,具体如下:在Report Server中存在一个报表,报表中有一个参数doctor_name,该参数允许多值,默认全部。但是由于前端页面医生选择时多选没有意义,因此,需要单选,但是在其他页面中存在多选的需求,因此这里还将doctor_name设置为allow multiple values。因此,具体需求为,前端页面选择一个医生时,就查询该医生的报表信息,但未选择任何医生时,就默认选择全部医生(相当于多值)。

二、解决方案                                                                                           

  我们设置数据集查询语句

SELECT  ... FROM ...    WHERE   (yourcolumname IN (@doctor_name))

  设置数据集的为参数表达式

  参数表达式为:

=SPLIT(JOIN(Parameters!doctor_name.Value,","),",")

    此时,在前端aspx页面的后台,我们就可以传过来一个数组了

 string[] doctorlist = new string[this.lbxListDoctor.Items.Count];
 for (int i = 0; i < this.lbxListDoctor.Items.Count; i++)
 {
     doctorlist[i] = this.lbxListDoctor.Items[i].Value;
 }
 var rpdoctor = new Microsoft.Reporting.WebForms.ReportParameter("doctor_name", doctorlist);
 serverReport.SetParameters(rpdoctor); 
原文地址:https://www.cnblogs.com/mingcaoyouxin/p/3992200.html