468,308 Members | 1,212 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,308 developers. It's quick & easy.

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 8612
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Oliver Drobnik | last post: by
reply views Thread by Ryan | last post: by
11 posts views Thread by Tim Frawley | last post: by
3 posts views Thread by Craig | last post: by
1 post views Thread by =?Utf-8?B?UnlhbiBBbmRydXM=?= | last post: by
3 posts views Thread by fniles | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.