473,385 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1583
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ed_P. | last post by:
Hello, I have a situation that I wish some help with. I have a DataSet object with DataTables populated from a ms access database. Each DataTable has a RunLogTitle. I have a TreeView object...
8
by: Dave Hagerich | last post by:
I'm using a DataGrid with a DataSet and I'm trying to filter the data being displayed, using the following code as a test: DataView theView = new DataView(theDataSet.Tables); theView.RowFilter =...
36
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
13
by: Steve | last post by:
I have a form with a dataset and a datagrid. I created a dataview on this dataset. When the user modifies the datagrid, I look up this record in the dataview to make sure it is unique. Here is...
11
by: Tim Frawley | last post by:
I need to return a DataRow or the Row Index in a DataSet wherein the value I am attempting to find is not a primary key. I have to do this often, more than 200 times when importing a file so it...
5
by: David Wender | last post by:
I want to create a dataview with a sort on multiple columns. However, when I use FindRows, I only want to search some of the columns, not all. Is this possible? I have not been able to make it...
2
by: DraguVaso | last post by:
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 =...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
4
by: James | last post by:
Basically I have a DataGrid that I'm binding to the results of a stored procedure call. The recordset is fairly small. Initially I'm creating a DataSet from the results and binding it. There's a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.