473,473 Members | 2,232 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

using defaultview.rowfilter on a dataset problem

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
6 12321
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
Hi,

try

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

Regards,
Filipe Marcelino

Nov 21 '05 #3
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: James | last post by:
I have a DataSet with two tables and two datagrids with a Parent/Child Relationship. While that works fine, setting a Rowfilter to the Parent on the parent table defaultview does not. If I use a...
0
by: Ian Bennett via .NET 247 | last post by:
Is there any way a datatable, that is populated with te colums Hdate, State1, State2, State3, etc can be filtered with an OR condition? The dt is populated by selecting the colums Hdate and State1,...
4
by: Joerg M. Colberg | last post by:
Hi all, I have a problem when using a DataSet. I am using it to query a SQLServer database as follows. In my code it looks like SqlDataAdapter eDA = new SqlDataAdapter(sqlcmd); // where...
2
by: David | last post by:
Hi, I use DataView to filter my record. But when I use: ls_filter += " and DATEPART(hh, CA103)=" + i ; mydv.RowFilter = ls_filter; I got error. How should I filter by hour using...
0
by: Paul Meller | last post by:
Hi, I am having a bit of trouble with a string used to filter a dataview in ASP.NET. Although the code I have works perfectly in almost all instances, there is a problem when using a string...
1
by: hoadley | last post by:
I am filtering a data table using the defaultView.rowFilter but when I filter a column of type "dateTime" it throws an exception saying " operator >= can not be used on type dateTime and type...
0
by: Babak | last post by:
Hi I am trying to find a way to fliter a DefaultView to filter Time Stamp DataTime For example I want to know if there is any row that have Time stmp greater then Today . The Datadiff function...
7
by: Bob | last post by:
Hi, I have a typed unbound dataset that is passed to a datahandling class to be filled. The datahandling class fills it from a sproc using an oledbDataAdapter (SQLAnywhere database) The only...
0
by: Jinu | last post by:
I am filtering a data table using the defaultView.rowFilter but when I filter a column of type "float" it throws an exception saying " operator = can not be used on type string and type double" ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.