locked
how to call multi-value parameters in SSRS from asp.net application? RRS feed

  • Question

  • User1557536560 posted

    hi all

    i am trying to call an SSRS report (in VS 2005) from my asp.net (web application) implemented in VS 2008 (don't ask me why, i am kind of confused by this weird arrangement too). report has been deployed to report server and it contains a multi-value parameter.

    when i call report from asp.net app, i set the value for this multi-value parameter as a string and all selected values are separated by comma. i.e. i have 5 options (a, b, c, d, e), and i selected first two, the string is then "a,b".

    the multi-value parameter on the report side is defined as: Multi-value selected, Allow blank selected, Avaliable values are from query (a dataset that contains a, b, c, d, e) Value field and Label field are both mapped to dataset filed (there is only one field in the dataset). the default values are from query too (same dataset). value field is mapped also.

    i have two problems:

    1: it looks to me that all available values are selected on the report side, regardless what i really selected and passed over (when i turn on paramters).

    2: when i turn off parameters, i need to display what values being selected as a string, the join statement, join(Parameters!TeamLead.Value), gives a list of all available values for the multi-value parameter, however, i only need selected values. how should i write this expression (for a textbox) to join only selected items in the multi-value parameter (i don't see any option in the intellisense dropdown box)?

    thanks a lot

    michael huang

     

     

    Wednesday, October 6, 2010 6:34 PM

All replies

  • User9812958 posted

    Are you using the ReportExecution webservice, or the Report Viewer control?

    If you use the webservice, each selected value should be sent in a separate instance of ParameterValue to the Render method. (For instance Render(..., new ParameterValue[] { new ParameterValue { Name = "TeamLead", Value = "a" }, new ParameterValue { Name = "TeamLead", Value="b" } }, ...))

    Parameters!TeamLead.Value should be an array containing only the selected values for the parameter, so your expression is correct.

    Thursday, October 7, 2010 2:48 AM
  • User1557536560 posted

    thanks for your help and time. i am using report viewer. my problem is that if i multiple selection of parameter, i passed values in a string list separated by comma, and it does not work. the report side has nothing selected and thus wait for the input. if have pass a single value, everything is fine. if i pass nothing, all available values are selected which is what i want.

    so what is the string format to pass the multiple values for the multi-value parameter

    thanks 

    Thursday, October 7, 2010 2:11 PM
  • User-309740890 posted

    please share the solution if you figured it out... it is driving me crazy... thanks!

    Thursday, August 18, 2011 2:31 PM
  • User-1647955772 posted

    This is the exact problem i am facing. Please help me if some one has it figured out.

    Wednesday, March 7, 2012 8:51 AM
  • User-8475372 posted

    Do you want to pass the parameters (multiValued) from your application to the report server ? If yes, below snippet works:

    RptParameters[increment] = new Microsoft.Reporting.WebForms.ReportParameter();

    if (pair.Value.StartsWith("mul"))
    {
    ddlMultiSelect = pnlParameters.FindControl(pair.Value).Parent as DropCheck; // Find the multivalue parameter in your application

    string[] strValues = ddlMultiSelect.Text.Split(';');
    if (strValues.Count() > 1)
    {
    foreach (string str in strValues)
    {
    RptParameters[increment].Values.Add(str);
    }
    }
    else
    {
    RptParameters[increment].Values.Add(ddlMultiSelect.Text);
    }

    }

    reportViewer.ServerReport.SetParameters(RptParameters);
    reportViewer.ServerReport.Refresh();

    If you want to pass the multi value parameter from your stored procedure, write a function which splits the comma seperated values and use it in the main dataset where you display the report. Let me know if you guys need that snippet as well.

    Wednesday, March 7, 2012 9:47 AM