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 I convert IList to a DataSet, DataTable or DataView? =?Utf-8?B?Tmljaw==?= Microsoft ASP .NET 6 19th Jul 2006 07:39 PM
datagrid dataset dataview datatable sorting Nathan Franklin Microsoft VB .NET 0 19th Jan 2006 05:15 AM
Create DataView or DataTable from DataSet Christine Y. Microsoft ADO .NET 1 28th Oct 2005 09:23 PM
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 Dot NET 2 6th Aug 2004 01:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:31 PM.