473,416 Members | 1,520 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,416 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 8946
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",...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.