Sunday, 15 September 2013

c# - Filter report parameter valid values based on parameter dependencies -


I am working on ASP.NET application which allows users to select SSRS reports from a dropdown list, report Fill the parameter and then see the report in ReportViewer on the next page. Some of the parameters are valid values, which I get from the RDLC file using the code given below:

ValidValue [GetParameterValidValues ​​(string parameterName, string reportDirectory) {ServerReport ServerReport = New ServerReport (); String report ServerUrl = application ["ReportServerUrl"] as string; ServerReport.ReportPath = Report Directory + lbReports.SelectedItem.Value; Server report Report Server = Yuri (Report Server URL); Report ParameterInfo report parameter = server report. GetParameters () [parameterName]; Valid Values ​​[] Valid Values ​​= Report Parameters. Valid values ​​.oire (); Return a valid value; }

These values ​​are then added to the dynamically-generated dropdown lists on the page.

The problem is that in some cases parameter A can filter valid values ​​of parameter B. This functionality may be supervisor while selecting parameters in ReportViewer control

My question is, how can I apply this functionality to my code?

You should choose the parameter dependency values ​​each time the value is the second most dependent. I have found that the best solution is using a hash table according to this article:

Where you call GetItemParameters, check the loop through each to see whether their dependency is each Dependencies are later added to the hashtable to set the values ​​...

  Private parameter value [] _ParamDependenciesValues ​​= new parameterwalk [0]; Protected ItemParameter [] GetReportParameterDependencies () {ItemParameter [] parameter = _Rs.GetItemParameters (_ThisReportPath, null, true, _ParamDependenciesValues, null); If (param.length & gt; 0) {foreach (p) in the itemParameter parameter} {if (! P.Dependencies = null) {foreach (d on p.Dependencies d) {if {_Dependencies (_Dependencies.Contains (d)! Add (D, empty); }}}}} Return parameter; }  

Then, each time a parameter value is selected, you must set the parameter value in the array and then call the GetItemParameters with the dependancy values ​​

  Protected Zero SetParamValues ​​(ItemParameter [] parameter) {foreach (ItemParameter RP in the parameter) {if (Rp.Dependencies! = Null) {foreach (Rp.Dependencies in d) {var MyParamValue = _ParamDependenciesValues.FirstOrDefault (c = & gt; C.Name == D); If (myoparamvalue == tap) {array Resize (Rif _ParamDependenciesValues, _ParamDependenciesValues.Count () + 1); Var MyNewParamValue = New parameter value {name = D}; _ParamDependenciesValues ​​[_ParamDependenciesValues.Length - 1] = MyNewParamValue; MyParamValue = _ParamDependenciesValues.FirstOrDefault (c = & gt; c.Name == D); } If (_Dependencies.Contains (d)) {If (MyParamValue = Null & amp;! Amp;; _Dependencies [d] = Faucet) MyParamValue.Value = _Dependencies [d] .ToString (); }}}}}} Item parameter [] parameter = _Rs.GetItemParameters (_ThisReportPath, null, true, _ParamDependenciesValues, null); }  

All dependencies in all standards are resolved until it is resolved ...


No comments:

Post a Comment