ReportViewer with LocalReport: DataSource question

G

Guest

Hi!
I use a ReportViewer control to show a local report, defined as
EmbeddedResource (RDLC). The report definition file (RDLC) uses a DataTable
as DataSource.

My intention is to find an efficient way to filter the data that is shown by
the report.

My first attempt was to set the filter on the BindingSource that is defined
as ReportDataSource for the LocalReport.DataSources list of the ReportViewer.
The code fragment created by the Designer looks like this:

reportDataSource2.Name = "DataSet1_SomeDataTable";
reportDataSource2.Value = this.bindingSource1;
this.reportViewer1.LocalReport.DataSources.Add(reportDataSource2);

But when I set

this.bindingSource1.Filter = "ID=1";

(for example) before calling RefreshReport(), this doesn't have any effect,
the data shown by the report doesn't use the filter.

Given the fact, that the report definition itself sets a DataSource (in the
RDLC file), my question is: What is the true DataSource? What sense does it
make that the ReportViewer defines a DataSource for the report that doesn't
seem to be used?

Further question: in case my observation (the DataSource defined by the
ReportViewer not being used by the report) is true, how can I achieve an
efficient filtering? By using report parameters? I hesitated to do this
because I want to use a filter that can freely be defined (which doesn't seem
to be possible with report parameters).

Thanks a lot for any hint!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top