PC Review


Reply
Thread Tools Rate Thread

2 DataView's from 1 DataSet/DataTable influence each other...

 
 
DraguVaso
Guest
Posts: n/a
 
      6th Aug 2004
Hi,

I have 2 comboboxes, both bound to a different DataView, but thoe DataViews
are bound to 1 DataTable in 1 DataSet.
Like this:

Dim dvwList2 As New DataView
dvwList2 = MyDataSet.Tables("tblAccounts").DefaultView
dvwList2.Sort = "Account ASC"
cmbAccount.DataSource = dvwList2
cmbAccount.DisplayMember = "MaskAccount"
cmbAccount.ValueMember = "Account"
cmbAccount.Text = ""

Dim dvwList3 As New DataView
dvwList3 = MyDataSet.Tables("tblAccounts").DefaultView
dvwList3.Sort = "doccode ASC"
cmbDocCode.DataSource = dvwList3
cmbDocCode.DisplayMember = "doccode"
cmbDocCode.ValueMember = "Account"
cmbDocCode.Text = ""

The problem is: The sorting on the second DataView changes also the sorting
on the first DataView, so both are Sorted by "doccode ASC".

Why does this happen? I dodn't want my View to change things like that. Is
there a way to get arround this? Or Should I fill my Comboboxes another way?

Thanks a lot in advance,

Pieter


 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      6th Aug 2004
DraguVaso <(E-Mail Removed)> wrote:
> I have 2 comboboxes, both bound to a different DataView, but thoe DataViews
> are bound to 1 DataTable in 1 DataSet.
> Like this:
>
> Dim dvwList2 As New DataView
> dvwList2 = MyDataSet.Tables("tblAccounts").DefaultView
> dvwList2.Sort = "Account ASC"
> cmbAccount.DataSource = dvwList2
> cmbAccount.DisplayMember = "MaskAccount"
> cmbAccount.ValueMember = "Account"
> cmbAccount.Text = ""
>
> Dim dvwList3 As New DataView
> dvwList3 = MyDataSet.Tables("tblAccounts").DefaultView
> dvwList3.Sort = "doccode ASC"
> cmbDocCode.DataSource = dvwList3
> cmbDocCode.DisplayMember = "doccode"
> cmbDocCode.ValueMember = "Account"
> cmbDocCode.Text = ""
>
> The problem is: The sorting on the second DataView changes also the sorting
> on the first DataView, so both are Sorted by "doccode ASC".
>
> Why does this happen? I dodn't want my View to change things like that. Is
> there a way to get arround this? Or Should I fill my Comboboxes another way?


Those aren't two views - they're one view. When you use DefaultView,
that's a single view. If you want to make sure you use a different
view, use the DataView constructor.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
 
DraguVaso
Guest
Posts: n/a
 
      6th Aug 2004
Ouwch, does it work like that?
Thanks! It works great now!

"Jon Skeet [C# MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> DraguVaso <(E-Mail Removed)> wrote:
> > I have 2 comboboxes, both bound to a different DataView, but thoe

DataViews
> > are bound to 1 DataTable in 1 DataSet.
> > Like this:
> >
> > Dim dvwList2 As New DataView
> > dvwList2 = MyDataSet.Tables("tblAccounts").DefaultView
> > dvwList2.Sort = "Account ASC"
> > cmbAccount.DataSource = dvwList2
> > cmbAccount.DisplayMember = "MaskAccount"
> > cmbAccount.ValueMember = "Account"
> > cmbAccount.Text = ""
> >
> > Dim dvwList3 As New DataView
> > dvwList3 = MyDataSet.Tables("tblAccounts").DefaultView
> > dvwList3.Sort = "doccode ASC"
> > cmbDocCode.DataSource = dvwList3
> > cmbDocCode.DisplayMember = "doccode"
> > cmbDocCode.ValueMember = "Account"
> > cmbDocCode.Text = ""
> >
> > The problem is: The sorting on the second DataView changes also the

sorting
> > on the first DataView, so both are Sorted by "doccode ASC".
> >
> > Why does this happen? I dodn't want my View to change things like that.

Is
> > there a way to get arround this? Or Should I fill my Comboboxes another

way?
>
> Those aren't two views - they're one view. When you use DefaultView,
> that's a single view. If you want to make sure you use a different
> view, use the DataView constructor.
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Combo Box A influence the choices in Combo Box B Paul Warnack Microsoft Access Forms 3 27th Oct 2004 09:00 AM
Influence of PrintDialog on PrintDocument's settings Tommy Carlier Microsoft Dot NET Framework 0 30th Sep 2004 08:15 AM
ANN: Excerpts from "Speak to Influence" Geetesh Bajaj Microsoft Powerpoint 0 7th Aug 2004 05:01 AM
2 DataView's from 1 DataSet/DataTable influence each other... DraguVaso Microsoft ADO .NET 2 6th Aug 2004 01:33 PM
2 DataView's from 1 DataSet/DataTable influence each other... DraguVaso Microsoft VB .NET 2 6th Aug 2004 01:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:00 PM.