By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,642 Members | 1,474 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,642 IT Pros & Developers. It's quick & easy.

using defaultview.rowfilter on a dataset problem

P: n/a
I am trying to setup a filter for the dataset on a form as follows:

Me.Ds1.Tables("company").DefaultView.RowFilter = "city='New York'"
But nothing happens when this code is executed. The same 7k records are
available in the databindings.

What am I missing here conceptually? Should I be applying this to the
bindingManagerBase or something?

Thanks.
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
I believe your controls are binded to a datatable, which dont have Filter
actions available.

So, if you use the DefaultView, this view is autocreated and autodestroied
when the code run out of that line.

What you need to do is bind your controls to a dataview which needs to keep
itself alive with your program.

[]s
Cesar


"astro" <as***@mnrr.com> escreveu na mensagem
news:LU******************@tornado.rdc-kc.rr.com...
I am trying to setup a filter for the dataset on a form as follows:

Me.Ds1.Tables("company").DefaultView.RowFilter = "city='New York'"
But nothing happens when this code is executed. The same 7k records are
available in the databindings.

What am I missing here conceptually? Should I be applying this to the
bindingManagerBase or something?

Thanks.

Nov 21 '05 #2

P: n/a
Hi,

try

Me.Ds1.COMPANY.DefaultView.RowFilter = ""
Me.Ds1.COMPANY.DefaultView.RowFilter = "city='New York'"

Regards,
Filipe Marcelino

Nov 21 '05 #3

P: n/a
I'll give that a try

)

"Ronchese" <ro******@smlinfo.com.br> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
I believe your controls are binded to a datatable, which dont have Filter
actions available.

So, if you use the DefaultView, this view is autocreated and autodestroied
when the code run out of that line.

What you need to do is bind your controls to a dataview which needs to
keep
itself alive with your program.

[]s
Cesar


"astro" <as***@mnrr.com> escreveu na mensagem
news:LU******************@tornado.rdc-kc.rr.com...
I am trying to setup a filter for the dataset on a form as follows:

Me.Ds1.Tables("company").DefaultView.RowFilter = "city='New York'"
But nothing happens when this code is executed. The same 7k records are
available in the databindings.

What am I missing here conceptually? Should I be applying this to the
bindingManagerBase or something?

Thanks.

Nov 21 '05 #4

P: n/a
Hi,

"astro" <as***@mnrr.com> wrote in message
news:LU******************@tornado.rdc-kc.rr.com...
I am trying to setup a filter for the dataset on a form as follows:

Me.Ds1.Tables("company").DefaultView.RowFilter = "city='New York'"
The DefaultView will be used if you have bound to control directly to a
DataTable or offcourse to the DefaultView. But the DefaultView will *not*
be used (for binding) if you have bound the control to a DataSet.


But nothing happens when this code is executed. The same 7k records are
available in the databindings.

What am I missing here conceptually? Should I be applying this to the
bindingManagerBase or something?
It doesn't matter to what you bind (well except for custom collection), the
bindings will internally always use a DataView, which is as explained
earlier not necessarily the DefaultView.

You can get the DataView used internally using a CurrencyManager( inherits
from BindingManagerBase ):

' It is important for the code below that you use the same
' DataSource and DataMember(without any field) as the
' ones you used for the binding.

Dim cm As CurrencyManager = DirectCast( _
BindingContext(dataSource, dataMember), _
CurrencyManager )

Dim dv As DataView = _
DirectCast( cm.List, DataView )

dv.RowFilter = "....."
HTH,
Greetings

Thanks.

Nov 21 '05 #5

P: n/a
I've gotten the textboxes bound to the dataview...

getting the comboboxes bound is another story.....

Me.cboIndustry.DataSource = mDV

Me.cboIndustry.DisplayMember = "NAICSdesc"

Me.cboIndustry.ValueMember = "industryID"

Me.cboIndustry.DataBindings.Remove(Me.cboIndustry. DataBindings(0))

Me.cboIndustry.DataBindings.Add(New
System.Windows.Forms.Binding("SelectedValue", mdv, "industryID"))

yields "system.data.datarowView" in the combobox.....

Is there an easier way to do this rather then looping through the controls
and manually repointing them to the DataView? Can't I redirect the form
binder instead?

How difficult does it have to be to put one filter on a form's dataset?

(sorry - blowing off some steam)

"Ronchese" <ro******@smlinfo.com.br> wrote in message
news:OL**************@TK2MSFTNGP10.phx.gbl...
I believe your controls are binded to a datatable, which dont have Filter
actions available.

So, if you use the DefaultView, this view is autocreated and autodestroied
when the code run out of that line.

What you need to do is bind your controls to a dataview which needs to
keep
itself alive with your program.

[]s
Cesar


"astro" <as***@mnrr.com> escreveu na mensagem
news:LU******************@tornado.rdc-kc.rr.com...
I am trying to setup a filter for the dataset on a form as follows:

Me.Ds1.Tables("company").DefaultView.RowFilter = "city='New York'"
But nothing happens when this code is executed. The same 7k records are
available in the databindings.

What am I missing here conceptually? Should I be applying this to the
bindingManagerBase or something?

Thanks.

Nov 21 '05 #6

P: n/a
that worked !

thanks )

"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:ud**************@TK2MSFTNGP15.phx.gbl...
Hi,

"astro" <as***@mnrr.com> wrote in message
news:LU******************@tornado.rdc-kc.rr.com...
I am trying to setup a filter for the dataset on a form as follows:

Me.Ds1.Tables("company").DefaultView.RowFilter = "city='New York'"


The DefaultView will be used if you have bound to control directly to a
DataTable or offcourse to the DefaultView. But the DefaultView will
*not* be used (for binding) if you have bound the control to a DataSet.


But nothing happens when this code is executed. The same 7k records are
available in the databindings.

What am I missing here conceptually? Should I be applying this to the
bindingManagerBase or something?


It doesn't matter to what you bind (well except for custom collection),
the bindings will internally always use a DataView, which is as explained
earlier not necessarily the DefaultView.

You can get the DataView used internally using a CurrencyManager( inherits
from BindingManagerBase ):

' It is important for the code below that you use the same
' DataSource and DataMember(without any field) as the
' ones you used for the binding.

Dim cm As CurrencyManager = DirectCast( _
BindingContext(dataSource, dataMember), _
CurrencyManager )

Dim dv As DataView = _
DirectCast( cm.List, DataView )

dv.RowFilter = "....."
HTH,
Greetings

Thanks.


Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.