Hi all, I have written a replacement for the report viewer web control that works extremely well but for one thing.
In summary I am dynamically building an interface for the report filters and then pass in a collection of parameter names and selected values. For this example my UI consists of 3 multi-select dropdowns where the content of dropdown 2 depends on the selection in dropdown 1 and dropdown 3 depends on the selection in dropdown 2. When a value changes in dropdown 1 I make a postback passing the UI values in order to get the default values for dropdown 2 and of course the same process to populate dropdown 3 when the value changes in dropdown 2. With me so far?
I am using ReportingService2010 and calling GetItemParameters, with the render option set to false, to get all of the parameter info that I need.
client.GetItemParameters(criteria.Path + criteria.Report, null, false, null, null).ToList();
I am then iterating through the returned parameters and building up a dictionary of parameter dependencies and values (values are extracted by parameter name from the passed in UI collection mentioned above).
// Now check other dependencies if (param.Dependencies != null) { foreach (var d in param.Dependencies) { if (!dependencies.ContainsKey(d)) { // Check if we a valid value in the response collection to be able to set the dependency value var response = criteria.Responses.FirstOrDefault(r => r.Title == d.ToString()); if (response != null && !string.IsNullOrEmpty(response.Value)) { var paramDetail = unrenderedParameters.FirstOrDefault(p => p.Name == d); switch (paramDetail.ParameterTypeName) { case "DateTime": DateTime validDate = DateTime.ParseExact(response.Value, "d/M/yyyy", CultureInfo.InvariantCulture); dependencies.Add(d, new ParameterValue() { Name = d, Label = d, Value = validDate.ToString("yyyy-MM-dd") }); break; default: dependencies.Add(d, new ParameterValue() { Name = d, Label = d, Value = response.Value.Trim() }); break; } } } } }
Once I have done I then again call GetItemParameters with the render option set to true and also pass in the dependency parameter and value collection in order to resolve the dependencies like so
client.GetItemParameters(criteria.Path + criteria.Report, null, true, dependencies.Values.ToArray(), null).ToList();
Now this is where I am hitting a problem. I would expect that after selecting a value in dropdown 1, setting render to true and passing the dependant values in a call to GetItemParameters that I would get the default values for dropdown 2 populated but I don't. The status for dropdown 2 is always 'HasOutstandingDependencies'.
I am assuming that I need to somehow loop through the parameters to resolve all dependencies but I cannot figure out what I would need to do any different to what I already am consider the dependant values are already being passed. Any ideas?