472,805 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

determining the index of a row in a datatable

Sorry if this is has an obvious answer, but I can't find it...

I am using a datatable.select to obtain the rows in a datatable that meet
certain criteria. My question is this: for each of the datarows that are
returned to me as a result of the datatable.select how can I determine their
index in the datatable.rows collection?

For those interested in why, it is because the index in the datatable is the
same as the index of the same row in an infergistics ultragrid control, and
I need to access that row in the grid, and the grid itself does not have the
equivalent of the "datatable.select", so I would have to scan through all
the rows which would be too inefficient. So, I'm sort of cheating by using
the fact that the field I'm searching for is a primary key and I can use the
datatable.select method to quickly find it. Hopefully, I can then use the
index of the datatable as the index into the ultragrid to access my row.

Thanks, John
Nov 21 '05 #1
2 8916
Hi,

http://www.vb-tips.com/default.aspx?...5-b1ec09f63071

Ken
-----------------
"JohnR" <Jo******@hotmail.com> wrote in message
news:NnT9f.334$Ul3.226@trndny07...
Sorry if this is has an obvious answer, but I can't find it...

I am using a datatable.select to obtain the rows in a datatable that meet
certain criteria. My question is this: for each of the datarows that are
returned to me as a result of the datatable.select how can I determine
their index in the datatable.rows collection?

For those interested in why, it is because the index in the datatable is
the same as the index of the same row in an infergistics ultragrid
control, and I need to access that row in the grid, and the grid itself
does not have the equivalent of the "datatable.select", so I would have to
scan through all the rows which would be too inefficient. So, I'm sort
of cheating by using the fact that the field I'm searching for is a
primary key and I can use the datatable.select method to quickly find it.
Hopefully, I can then use the index of the datatable as the index into the
ultragrid to access my row.

Thanks, John

Nov 21 '05 #2
Hi Ken,

Thanks for your response, but I'm a little confused... it seems your
example shows how to find the datarow given the position in the
currencymanager. What I am looking for is how to find the index of a row
that is returned to me as a result of a DataTable.Select method.

Something like this:

FoundRows = DataSet.Tables("MyTable").Select("MyField = 'Hi There'")
'return row where primary key is "Hi There"
dim dr as datarow = FoundRows(0) 'get the first found row
dim RowIndex as integer = dr.GetRowIndex 'of course there is no such
method, but it is what I am looking for
'once I have the rowindex I can do this:
dr = DataSet.Tables("MyTable").rows(RowIndex) 'and this stmt will return
the same row as before

So my question is how can I find RowIndex for a DataRow given I have the
actual DataRow object?

Thanks, John
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:u5*************@TK2MSFTNGP15.phx.gbl...
Hi,

http://www.vb-tips.com/default.aspx?...5-b1ec09f63071

Ken
-----------------
"JohnR" <Jo******@hotmail.com> wrote in message
news:NnT9f.334$Ul3.226@trndny07...
Sorry if this is has an obvious answer, but I can't find it...

I am using a datatable.select to obtain the rows in a datatable that meet
certain criteria. My question is this: for each of the datarows that are
returned to me as a result of the datatable.select how can I determine
their index in the datatable.rows collection?

For those interested in why, it is because the index in the datatable is
the same as the index of the same row in an infergistics ultragrid
control, and I need to access that row in the grid, and the grid itself
does not have the equivalent of the "datatable.select", so I would have
to scan through all the rows which would be too inefficient. So, I'm
sort of cheating by using the fact that the field I'm searching for is a
primary key and I can use the datatable.select method to quickly find it.
Hopefully, I can then use the index of the datatable as the index into
the ultragrid to access my row.

Thanks, John


Nov 23 '05 #3

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

Similar topics

3
by: Oliver Drobnik | last post by:
Hi, I have a datagrid bound to a datatable. Now if I sort the datagrid by clicking on one of the column heads I can no longer use the index in the datagrid to find the corresponding row in the...
2
by: Clinton Pierce | last post by:
I've filled a DataTable with columns that have custom type (a class that I'm using to keep track of other things, not just a value). When the .Select method goes to sort this column, how do I let...
0
by: Ryan | last post by:
Is there a way to get a row's DataView index from the underlying DataTable index. Example DataTable (sorted by key - 1st column) DataView (sorted by second column) Row 0 - A, 2 ...
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...
3
by: Craig | last post by:
I know this is retarded but can you help: I'm using Visual Basic .net and I'm trying to determine the row ID from a dataset find i.e. Dim rowFoundRow As DataRow =...
5
by: Nathan Sokalski | last post by:
I have a control that I want displayed in all items except the last one. I figured the best way to do this was to determine whether the current item was the last from within the ItemDataBound event...
0
by: dalaeth | last post by:
I have searched Google high and low and haven't found anything that works. Here's my problem, hopefully someone will be able to help! I'm using 1.1 Framework, and ODP.NET 9.5.0.7 on a Windows...
1
by: =?Utf-8?B?UnlhbiBBbmRydXM=?= | last post by:
Does the int index of the DataTable.Rows collection place a size limit on how large a datatable can be? If not then how do you index DataTable.Rows for sizes greater than what an int can handle?
3
by: fniles | last post by:
Can I create an index on a DataTable ? On the following DataTable, I would like to create index on "Price", can I do that ? Thank you. Dim DT As New DataTable DT.Columns.Add("Price",...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.