Home All Groups Group Topic Archive Search About

Change Report Data Source

Author
13 Nov 2006 4:52 PM
William LaMartin
I have report based on a datasource (a tableadapter) that supplies names,
street addresses, cities, etc. to be displayed in a report viewer.

Is there a way in code to modify this report to only show the information
for a certain city provided by the user's entry in a text box?

Author
14 Nov 2006 2:30 AM
RobinS
If you have a DataSet and aren't doing data binding, you
can use the inherent DataView class to filter the DataSet.

Dim myDataView = New DataView(myDataSet.Tables("Customers"))
myDataView.Filter = "country = 'Germany'"

If you do this, you will have to use the DataView to display
the data on the report, not the DataSet.

If the report is databound, you can insert a binding source
in between the dataset and the report, and use that to
filter the data.

'GetCustomers fills the Customers table in the Dataset
Dim nwData as CustomersDataSet = CustomersDataSet.GetCustomers()
myReport.DataSource = m_CustomersBindingSource
m_CustomersBindingSource.DataSource = nwData.Customers

Then you can apply a filter to the BindingSource like this:

CustomersBindingSource.Filter = "Country = 'Germany'"

Hope that helps.
Robin S.
-------------------



Show quoteHide quote
"William LaMartin" <lamar***@tampabay.rr.com> wrote in message
news:OH7GYQ0BHHA.4844@TK2MSFTNGP02.phx.gbl...
>I have report based on a datasource (a tableadapter) that supplies names,
>street addresses, cities, etc. to be displayed in a report viewer.
>
> Is there a way in code to modify this report to only show the information
> for a certain city provided by the user's entry in a text box?
>
Author
14 Nov 2006 2:45 AM
William LaMartin
Thanks.

Show quoteHide quote
"RobinS" <RobinS@NoSpam.yah.none> wrote in message
news:DK2dnYXlN8qzt8TYnZ2dnUVZ_oCdnZ2d@comcast.com...
> If you have a DataSet and aren't doing data binding, you
> can use the inherent DataView class to filter the DataSet.
>
> Dim myDataView = New DataView(myDataSet.Tables("Customers"))
> myDataView.Filter = "country = 'Germany'"
>
> If you do this, you will have to use the DataView to display