How do I programmatically access the value of a report parameter in the report viewer control? RRS feed

  • Question

  • I am currently developing an executive dashboard web application which contains several pages which have either a pie and/or bar chart followed by a table including a more detailed view of the data.  Since the charts also need to be seen independently of the tables, they are all in seperate reports and report viewer controls.  On all of the pages are two controls which allow the user to select the time period and part of the organizational heirarchy for which to view the data.  These control the parameters for every report viewer on the page.  I have then hidden the parameter prompts for each report viewer and programmatically control all of the parameters.


    I am now working on a report which doesn't follow the standards of all the previous reports.  The detailed view must be a matrix.  Since the horizontal scrolling is awkward and most users will have only two or three groups they care to see at any given time, I have added a report parameter to control which groups they see.  The default for this parameter is all groups.  I have then hidden all the other parameters and set the report viewer to display the Report Parameters so the user can change it.  It works beautifully when the user changes the groups refreshes the report.


    My problem is that when the user changes either the time period or current place in the heirarchy, the matrix report naturally resets to the default value.  I need a way to access the current value of the groups parameter so that I can save it off and submit the current selection to the report when I refresh it.  Is there a way to do this?


    I have considered using a ListBox control for this feature and hiding the parameter in the report viewer, but there are a number of reasons which make this very awkward in the interface.


    I have attempted to use the Controls property of the ReportViewer object to see what this really gives me.  When I attempt to access myReportViewer.Controls.Item(n) in the watch window, I get the output: "'System.Web.UI.ControlCollection' does not contain a definition for 'Item'."  This appears to be in contradiction with the documentation for the ControlCollection class.  Is this a bug or an error in the documentation?  If this worked right, would it even get me what I'm looking for?




    Friday, January 18, 2008 6:48 PM