By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,706 Members | 1,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,706 IT Pros & Developers. It's quick & easy.

determining the index of a row in a datatable

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.