469,963 Members | 1,806 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,963 developers. It's quick & easy.

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

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
Jul 21 '05 #1
2 1441
DraguVaso <pi**********@hotmail.com> 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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Ouwch, does it work like that?
Thanks! It works great now!

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
DraguVaso <pi**********@hotmail.com> 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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ed_P. | last post: by
8 posts views Thread by Dave Hagerich | last post: by
13 posts views Thread by Steve | last post: by
11 posts views Thread by Tim Frawley | last post: by
4 posts views Thread by James | last post: by
1 post views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.