473,772 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple DataViews on the same DataTable appear to interact

I have a DataTable that is being maintained in a Model class. I also have a
View class which creates a DataView from the DataTable that the Model passes
it. The view class then has methods to filter the contents of the DataView
so that the user can narrow down the list to the items they are interested
in. This all works fine as long as I only have a single instance of the
View class, however whenever I create a second instance of the view class
and have it make its DataView use the same DataTable I find that any filter
applied to the DataView in one window is also applied to the DataView in the
other form. Can anyone explain this to me? It seems that as long as I am
using 2 independant DataViews (dim dv as new DataView(model. GetTable()) they
shouldn't interact.

TIA
Ron L
Nov 21 '05 #1
5 3200
Ron,
The problem is that all the views are connected to the same table. To avoid
this, when creating additional views, create the main table from your Model
class and use separate copy of this table for each view:

dim t2 as Datatable = tMain.Copy
dim dv2 = t2.DefaultView
DataGrid2.DataS ource = dv2

This way each view is connected to a different table and filtering one will
not affect the others.

Hope that helps,
Daniel

"Ron L" wrote:
I have a DataTable that is being maintained in a Model class. I also have a
View class which creates a DataView from the DataTable that the Model passes
it. The view class then has methods to filter the contents of the DataView
so that the user can narrow down the list to the items they are interested
in. This all works fine as long as I only have a single instance of the
View class, however whenever I create a second instance of the view class
and have it make its DataView use the same DataTable I find that any filter
applied to the DataView in one window is also applied to the DataView in the
other form. Can anyone explain this to me? It seems that as long as I am
using 2 independant DataViews (dim dv as new DataView(model. GetTable()) they
shouldn't interact.

TIA
Ron L

Nov 21 '05 #2
Some further, amplifying information, the interaction we are seeing is with
datagrids on each form, each bound to its own dataview.

TIA
Ron L

"Ron L" <ro**@bogus.Add ress.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I have a DataTable that is being maintained in a Model class. I also have
a View class which creates a DataView from the DataTable that the Model
passes it. The view class then has methods to filter the contents of the
DataView so that the user can narrow down the list to the items they are
interested in. This all works fine as long as I only have a single
instance of the View class, however whenever I create a second instance of
the view class and have it make its DataView use the same DataTable I find
that any filter applied to the DataView in one window is also applied to
the DataView in the other form. Can anyone explain this to me? It seems
that as long as I am using 2 independant DataViews (dim dv as new
DataView(model .GetTable()) they shouldn't interact.

TIA
Ron L

Nov 21 '05 #3
Daniel

Thanks for the response. The problem with keeping multiple copies is that
the tables can be updated, and I want to be able to perform the update in
one place. I suppose, if I have to, I can keep track of the copies in a
central location and perform the update on all of them whenever it happens.
I was hoping that I wouldn't need to add that complexity.

Ron L
"Daniel" <Da****@discuss ions.microsoft. com> wrote in message
news:54******** *************** ***********@mic rosoft.com...
Ron,
The problem is that all the views are connected to the same table. To
avoid
this, when creating additional views, create the main table from your
Model
class and use separate copy of this table for each view:

dim t2 as Datatable = tMain.Copy
dim dv2 = t2.DefaultView
DataGrid2.DataS ource = dv2

This way each view is connected to a different table and filtering one
will
not affect the others.

Hope that helps,
Daniel

"Ron L" wrote:
I have a DataTable that is being maintained in a Model class. I also
have a
View class which creates a DataView from the DataTable that the Model
passes
it. The view class then has methods to filter the contents of the
DataView
so that the user can narrow down the list to the items they are
interested
in. This all works fine as long as I only have a single instance of the
View class, however whenever I create a second instance of the view class
and have it make its DataView use the same DataTable I find that any
filter
applied to the DataView in one window is also applied to the DataView in
the
other form. Can anyone explain this to me? It seems that as long as I
am
using 2 independant DataViews (dim dv as new DataView(model. GetTable())
they
shouldn't interact.

TIA
Ron L

Nov 21 '05 #4
Ron,

Maybe you can work around this by refreshing the datasource views for each
datagrid everytime the user updates the main database. You don't need to keep
track of the multiple copies, just create the new copy, and pass its default
dataview to the datagrid as datasource each time the user updates the
database.
I am not sure if that will fit your needs, but I used it to solve a similiar
problem and it worked fine.

Daniel

"Ron L" wrote:
Daniel

Thanks for the response. The problem with keeping multiple copies is that
the tables can be updated, and I want to be able to perform the update in
one place. I suppose, if I have to, I can keep track of the copies in a
central location and perform the update on all of them whenever it happens.
I was hoping that I wouldn't need to add that complexity.

Ron L
"Daniel" <Da****@discuss ions.microsoft. com> wrote in message
news:54******** *************** ***********@mic rosoft.com...
Ron,
The problem is that all the views are connected to the same table. To
avoid
this, when creating additional views, create the main table from your
Model
class and use separate copy of this table for each view:

dim t2 as Datatable = tMain.Copy
dim dv2 = t2.DefaultView
DataGrid2.DataS ource = dv2

This way each view is connected to a different table and filtering one
will
not affect the others.

Hope that helps,
Daniel

"Ron L" wrote:
I have a DataTable that is being maintained in a Model class. I also
have a
View class which creates a DataView from the DataTable that the Model
passes
it. The view class then has methods to filter the contents of the
DataView
so that the user can narrow down the list to the items they are
interested
in. This all works fine as long as I only have a single instance of the
View class, however whenever I create a second instance of the view class
and have it make its DataView use the same DataTable I find that any
filter
applied to the DataView in one window is also applied to the DataView in
the
other form. Can anyone explain this to me? It seems that as long as I
am
using 2 independant DataViews (dim dv as new DataView(model. GetTable())
they
shouldn't interact.

TIA
Ron L


Nov 21 '05 #5
Daniel

Thanks, I will take a look at that.

Ron L

"Daniel" <Da****@discuss ions.microsoft. com> wrote in message
news:99******** *************** ***********@mic rosoft.com...
Ron,

Maybe you can work around this by refreshing the datasource views for each
datagrid everytime the user updates the main database. You don't need to
keep
track of the multiple copies, just create the new copy, and pass its
default
dataview to the datagrid as datasource each time the user updates the
database.
I am not sure if that will fit your needs, but I used it to solve a
similiar
problem and it worked fine.

Daniel

"Ron L" wrote:
Daniel

Thanks for the response. The problem with keeping multiple copies is
that
the tables can be updated, and I want to be able to perform the update in
one place. I suppose, if I have to, I can keep track of the copies in a
central location and perform the update on all of them whenever it
happens.
I was hoping that I wouldn't need to add that complexity.

Ron L
"Daniel" <Da****@discuss ions.microsoft. com> wrote in message
news:54******** *************** ***********@mic rosoft.com...
> Ron,
> The problem is that all the views are connected to the same table. To
> avoid
> this, when creating additional views, create the main table from your
> Model
> class and use separate copy of this table for each view:
>
> dim t2 as Datatable = tMain.Copy
> dim dv2 = t2.DefaultView
> DataGrid2.DataS ource = dv2
>
> This way each view is connected to a different table and filtering one
> will
> not affect the others.
>
> Hope that helps,
> Daniel
>
> "Ron L" wrote:
>
>> I have a DataTable that is being maintained in a Model class. I also
>> have a
>> View class which creates a DataView from the DataTable that the Model
>> passes
>> it. The view class then has methods to filter the contents of the
>> DataView
>> so that the user can narrow down the list to the items they are
>> interested
>> in. This all works fine as long as I only have a single instance of
>> the
>> View class, however whenever I create a second instance of the view
>> class
>> and have it make its DataView use the same DataTable I find that any
>> filter
>> applied to the DataView in one window is also applied to the DataView
>> in
>> the
>> other form. Can anyone explain this to me? It seems that as long as
>> I
>> am
>> using 2 independant DataViews (dim dv as new
>> DataView(model. GetTable())
>> they
>> shouldn't interact.
>>
>> TIA
>> Ron L
>>
>>
>>


Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1491
by: Pablo | last post by:
Hi people, Necesito crear n dataviews en tiempo de ejecucion. I need to create "n" DataViews in runtime. I tried creating an array this way: Dim LDView As Array = Array.CreateInstance(GetType(DataView), 10)
1
1312
by: Vee Kay | last post by:
hi, this is my first post here. i'm in desparate need of resources for VC++.NET; the code in MSDN is only directed for VB/C#.. for C++ its very few and faar in between!! the web is no good either!! :'( now that my rant is over, here is my question: i have applied 2 dataviews on a datatable. now i want to iterate thru this dataview to see the underlying values. the views are being
1
1650
by: Kevin | last post by:
I have a 4 tab form each with different dataviews attached to a datagrid. On the last tab, I have a dataview attached to a datagrid and 2 comboxes that are bound to the same dataset representing 2 different columns in the dv. When I create cbSecond.BindingContext = new BindingContext(); the combox loads okay but the value does not change with the new row, nor do changes in the combox propogate to the dv. (combobox 1 works okay as long as...
1
1211
by: Terry McNamee | last post by:
Hi Nicholas, To give you a better understanding of what I'm doing... I'm using a ownerdrawnlist control that is used as a menu on the smartphone. To populate this menu, I iterate through the DataTable by: foreach (DataRowView row in view) {
3
1904
by: Jerry | last post by:
Hi, I have a couple of datagrids that are based on dataviews. If I filter dataview1 I would like to automatically filter dataview2. I posted something about this before but I think I didn't specifically focus about that I was using dataviews and just datagrids. Ken Tucker was nice enough to share an example using datagrids and relations/constraints from code (thanks ken). I was able to duplicate this example using components and...
13
1835
by: Lars Netzel | last post by:
hi! myDataSet that is fillled from an Access 2000 db and includes ONE table From that Table in myDataSet I create myDataView and use a Rowfilter to get a few rows that i work with (i need a DataView cause I do a lot of filtering) The problem is the primary key field (a unique counter), let's call it "TBL_ID".
9
20870
by: DraguVaso | last post by:
Hi, I have two DataTables (our DataViews or whatever that will suit the best for the solution). I want to merge these two DataTables the fastest as possible, but they have to be merged one table after the others: First all the recors of DataTable1, and afterwarths the records of DataTable2. Does anybody has any idea how to do this? The purpose it that it goes as fast as possible! DataTable2 can have up to 15.000 records, DataTable1...
4
1399
by: Bernie Hunt | last post by:
I currently have a datagrid that I'm feeding with a DataSet, which contains three tables. I would like to use a DataView to format the DataTables but I'm not sure how to go about this. Currently I have; dsVendorContacts is a DataSet with three tables and relational links dgVendors is a DataGrid With dgVendors
3
4482
by: TomH | last post by:
I am using VB within VS 2005. How can I have multiple datagridviews on the same form pulling from the same table? e.g. I want to see all clients from New York in one view and all clients from LA in another view on the same form. I've set up a parameterized tableadapter and pass it the city. How can I load the two views in VB code when the form loads? Thanks, Tom
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10103
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7460
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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 we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.