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

Multiple DataViews on the same DataTable appear to interact

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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.DataSource = 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

P: n/a
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.Address.com> wrote in message
news:%2****************@TK2MSFTNGP09.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

P: n/a
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****@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.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.DataSource = 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

P: n/a
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****@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.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.DataSource = 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

P: n/a
Daniel

Thanks, I will take a look at that.

Ron L

"Daniel" <Da****@discussions.microsoft.com> wrote in message
news:99**********************************@microsof t.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****@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.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.DataSource = 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 discussion thread is closed

Replies have been disabled for this discussion.