473,651 Members | 2,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Table s("tblAccounts" ).DefaultView
dvwList2.Sort = "Account ASC"
cmbAccount.Data Source = dvwList2
cmbAccount.Disp layMember = "MaskAccoun t"
cmbAccount.Valu eMember = "Account"
cmbAccount.Text = ""

Dim dvwList3 As New DataView
dvwList3 = MyDataSet.Table s("tblAccounts" ).DefaultView
dvwList3.Sort = "doccode ASC"
cmbDocCode.Data Source = dvwList3
cmbDocCode.Disp layMember = "doccode"
cmbDocCode.Valu eMember = "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 1605
DraguVaso <pi**********@h otmail.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.Table s("tblAccounts" ).DefaultView
dvwList2.Sort = "Account ASC"
cmbAccount.Data Source = dvwList2
cmbAccount.Disp layMember = "MaskAccoun t"
cmbAccount.Valu eMember = "Account"
cmbAccount.Text = ""

Dim dvwList3 As New DataView
dvwList3 = MyDataSet.Table s("tblAccounts" ).DefaultView
dvwList3.Sort = "doccode ASC"
cmbDocCode.Data Source = dvwList3
cmbDocCode.Disp layMember = "doccode"
cmbDocCode.Valu eMember = "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.co m>
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.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
DraguVaso <pi**********@h otmail.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.Table s("tblAccounts" ).DefaultView
dvwList2.Sort = "Account ASC"
cmbAccount.Data Source = dvwList2
cmbAccount.Disp layMember = "MaskAccoun t"
cmbAccount.Valu eMember = "Account"
cmbAccount.Text = ""

Dim dvwList3 As New DataView
dvwList3 = MyDataSet.Table s("tblAccounts" ).DefaultView
dvwList3.Sort = "doccode ASC"
cmbDocCode.Data Source = dvwList3
cmbDocCode.Disp layMember = "doccode"
cmbDocCode.Valu eMember = "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.co m>
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
2468
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 with TreeNodes that correspods to the Names of each DataTable's RunLogTitle. When the user clicks on a TreeNode the corresponding DataTable shows up in the DataGrid. This is working great, but I would want to use a DataView object to show only the...
8
3889
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 = "'Record ID' = '0'"; theView.RowStateFilter = DataViewRowState.ModifiedCurrent; Debug.WriteLine(string.Format("RowFilter = {0}", theView.RowFilter)); RecordDataGrid.DataSource = theView; RecordDataGrid.DataBind();
36
4460
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 dataview with a count = 0. Can someone explain why and how I might work around this problem? Here is the code for my function: Public Shared Function GetViewFromRS(ByVal pRS As ADODB.Recordset) _ As DataView
13
2095
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 the confusion......... I thought that the DataView is the view from the dataset, but it seems that the dataview has the records that are in the datagrid, because everytime I search for a record that I know is NOT in the dataset, it finds it. I...
11
27424
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 needs to be fast. Could I use a Dataview to filter for the value (which is unique) and return either the DataRow object so I can modify it and put it back into the DataSet the view is based on or somehow get the RowIndex in the DataSet that the...
5
8824
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 happen. Dim objKeys(2) as Object objKeys(0) = "CL" objKeys(2) = 4000 Dim posView As DataView = New DataView(posDS.Tables("Positions"), _
2
1213
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 = MyDataSet.Tables("tblAccounts").DefaultView dvwList2.Sort = "Account ASC" cmbAccount.DataSource = dvwList2
17
2747
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 allow user to filter the first time, when they tried the second time, the speficied cast error message will prompt one.... I create a mydataset1 first, and the mydataset1 data source was getting from DataGrid.DataSource.
4
1579
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 DropDownList on my page that filters the records that are displayed in the grid. How I'm currently handling this is when I initially bind, I create a DataView from the table in the dataset. When the DropDownList changes selection, I get the...
0
8357
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8803
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8581
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7298
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4285
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.