Filtering Data Dynamically on a ReportViewer Control
How to display Dynamic Data in the ReportViewer Control.
Imagine having a ReportViewer Control on either Winforms or Webform.
We use a SQL Query to fetch the data and have a dataset returned as a result of executing the SQL Query on the Database.
We have this Dataset assinged to the ReportViewer Control. We have some filter criteria mentioned on the form and based on the filter criteria the data on the ReportViewer Control needs to be refreshed.
Imagine having a button that generates the report. Assuming that all the datasets are previously populated with information, here is how I apply my filter and reassign my binding source.
Its not needed for us to touch the reportviewer control (other than to tell it to render) as it should already pointing to the binding source for its data.
Me.DataSet.DataTable.DefaultView.RowFilter = "" // Mention the filter condition you would like to use to filter the Data
Me.DataTableReportBindingSource.DataSource = Me.DataSet.DataTable.DefaultView
http://msdn2.microsoft.com/en-us/library/ms252125(VS.80).aspx [How to: Filter Data in a ReportViewer Report]