Hello, in reporting services I have to pass parameters as an arry, the problem is that I dont know the number of parameters that the user is going to select because one of those parameters is a multivalue parameter, So I used a constructor with a constant
number of 10 for example, then I iterate through the checkboxlist to know which checkboxes the user selected, as I have 2 already know parameters, the number of parameters will be minimum 2 if the user doesnt select nothing on the checkboxlist, if the user
selects 2 checkboxes list the parametervalue array will have 4 positions FILLED with data but the rest will be null, and I can send null parameters because I will have an error.
execInfo = rs.LoadReport(path, null);
ReportParameter[] reportparameters=execInfo.Parameters;
ParameterValue pNmEmpresa= new ParameterValue();
pNmEmpresa.Name = "NmEmpresa";
pNmEmpresa.Value = DropDownList1.SelectedValue;
//reportparameters[0] = pNmEmpresa;
ParameterValue pNmCiclo = new ParameterValue();pNmCiclo.Name =
"NmCiclo";pNmCiclo.Value = DropDownList2.SelectedValue;
//reportparameters[1] = pNmCiclo;////rs.SetExecutionParameters(); StringBuilder selectected = new StringBuilder(); int TiposCompetenciasSeleccionadas = 0; ArrayList al = new ArrayList(); for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items{
selectected.Append(CheckBoxList1.Items
.Value);
selectected.Append(
",");al.Add(CheckBoxList1.Items
.Value);
TiposCompetenciasSeleccionadas++;
}
}
ParameterValue[] parametros ;parametros =
new ParameterValue[10];parametros[0] = pNmEmpresa;
parametros[1] = pNmCiclo;
//{ pNmEmpresa, pNmCiclo }; //parametros.SetValue( for (int i = 0; i < al.Count; i++){
ParameterValue pNmTipoCompetencia = new ParameterValue();pNmTipoCompetencia.Name =
"NmTipoCompetencia";pNmTipoCompetencia.Value = (
string)alparametros[i + 2] = pNmTipoCompetencia;
//parametros[i+2].Name ="NmTipoCompetencia"; //parametros[i+2].Value = (string)al[1];}
parametros.
//string[] nmtiposcompetencia = selectected.ToString().Split(new char[] { ',' });
rs.SetExecutionParameters(parametros,
null); ---> This is the line of the error