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

Discussion in 'Microsoft Dot NET' started by DraguVaso, Aug 6, 2004.

  1. DraguVaso

    DraguVaso Guest

    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
     
    DraguVaso, Aug 6, 2004
    #1
    1. Advertisements

  2. DraguVaso <> 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 - <>
    http://www.pobox.com/~skeet
    If replying to the group, please do not mail me too
     
    Jon Skeet [C# MVP], Aug 6, 2004
    #2
    1. Advertisements

  3. DraguVaso

    DraguVaso Guest

    Ouwch, does it work like that?
    Thanks! It works great now!

    "Jon Skeet [C# MVP]" <> wrote in message
    news:...
    > DraguVaso <> 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 - <>
    > http://www.pobox.com/~skeet
    > If replying to the group, please do not mail me too
     
    DraguVaso, Aug 6, 2004
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tavish Muldoon

    Datasets, Dataviews and Webpages.

    Tavish Muldoon, Jul 8, 2003, in forum: Microsoft Dot NET
    Replies:
    2
    Views:
    421
    VijayShankar
    Jul 9, 2003
  2. Guest
    Replies:
    3
    Views:
    230
    Guest
    May 9, 2005
  3. Pieter
    Replies:
    13
    Views:
    245
    Jay B. Harlow [MVP - Outlook]
    Jan 25, 2006
  4. Albert Greinöcker

    Remoting - influence WSDL generation

    Albert Greinöcker, Mar 19, 2006, in forum: Microsoft Dot NET
    Replies:
    0
    Views:
    190
    Albert Greinöcker
    Mar 19, 2006
  5. Replies:
    0
    Views:
    566
Loading...

Share This Page