473,671 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to find row position after sorting dataview table

Hello,

I set a dataview to a table. Then I bind a currencyManager to the dataview.
I can iterate through the dataview no problem so far. Then I sort the
dataview on a certain field and rebind the currencyManager to the dataview.
I can still iterate through the newly sorted dataview OK. The problem is
that the row order of the underlying table did not change with the sort. Now
the rows are out of order if I want to set a datarow object to the currently
displayed row.

How can I determine what row I am on after doing a sort on a dataview?

Thanks,
Rich
Jun 1 '07 #1
1 2973
Nevermind, I figured it out:

Dim drF() As DataRow
drF = myDataset.Table s("myTable").Se lect("rowID = " & txtRowID.Text)
dr = drF(0)

rowID is the unique column in myTable. I use the Select method of the
DataTable object to retrieve all rows that have the given RowID (which will
be 1 row in my case since RowID is unique). I collect the returned rows in a
DataRow array, drF. Then I set a datarow object to the first row in drF(0).
"Rich" wrote:
Hello,

I set a dataview to a table. Then I bind a currencyManager to the dataview.
I can iterate through the dataview no problem so far. Then I sort the
dataview on a certain field and rebind the currencyManager to the dataview.
I can still iterate through the newly sorted dataview OK. The problem is
that the row order of the underlying table did not change with the sort. Now
the rows are out of order if I want to set a datarow object to the currently
displayed row.

How can I determine what row I am on after doing a sort on a dataview?

Thanks,
Rich
Jun 1 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1773
by: Dave S | last post by:
Hi, I'm using a datagrid to display contents of a dataset and I've set the datagrid to allow paging and sorting. Rather than re-retrieve from the DB, I store the original dataset in a Session variable and then rebind to it for each page (which works). I'd also like to be able to sort any of the columns of the datagrid, so I do this using a dataview as shown below triggered from the normal Grid_SortCommand event :
9
2578
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, in Window2K server"). First of all, here are the two methods I have used in order to apply the sorting property to the DataView 1. Simply defining the sort order and colum DataView...
2
945
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
4
10031
by: suzy | last post by:
hello. how can i sort data in a dataset? all the examples i have seen on msdn, etc are sorting a dataview. this works fine, but i want to return the results in xml and the dataview doesn't have a .getxml method (unlike the dataset). any ideas? thanks.
3
5345
by: Björn | last post by:
Hi List I´m generating a DataSet using a simple sql select statement. Now my DataSet has several rows with columns(ID,NAME,CAPTION) Now I want to sort the DataSet for column Caption. I can´t use sql "order by" because the caption field is of Sqltype text. So I wanted to use the DataView object sort order. ----sample code-------------------------- DataView sortView = this.sqlResultDS.Tables.DefaultView;//new
4
2612
by: Aaron Smith | last post by:
Dim dv As DataView = New DataView(FacilitiesDS1.Facilities, "", "ID ASC", DataViewRowState.CurrentRows) Dim iPos As Integer = dv.Find(dr.Item("ID")) Me.BindingContext(FacilitiesDS1, "Facilities").Position = iPos That is the code.. dr is DataRow. If dr.Item("ID") = 3, the find will return position 0, which it should have been 1, and if the ID = 2, it will return 1, which should have been 0.. The DA has a connection string that sorts it...
6
3342
by: David P. Donahue | last post by:
I've been looking around for ways to sort the rows in a DataTable, and everything seems to point to just changing the Sort property on that DataTable's DefaultView property. That's all well and good for viewing it sorted, but I need it to actually _be_ sorted, and testing seems to show that the view doesn't do the trick. If I iterate through the rows in my code and look at the sorted column in each step, it's not sorted. Now, I can...
2
2454
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I need to locate a row (or see if it exists) in a table contained in a dataset. The DataView.Find method seems to work OK for one criteria but I need to use 2 criterias. Is there anything in VB2005 that does was DLookUpd does in Access - but for a table contained in a Dataset? I realize that DLookUp works on Physical tables (not in-memory dataset tables), and I could use a sqlDataReader to find my row from the physical...
6
4068
by: =?Utf-8?B?RGFu?= | last post by:
I am reposting a question from about 3 weeks ago ("sorting capability"). I have an aspx page in which I get the data from a database dynamically, through C# code, by creating a dynamic table using TableHeaderCell and TableHeaderRow. The data is binded to the table by using a DataSet and Data Reader. The responses on the forum made me think that it would be easier to sort the data in the table (when clicking on the header column), by...
0
8472
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
8390
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8667
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
7428
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...
0
4221
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
4399
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1801
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.