Item Index in dataset

  • Thread starter Thread starter Matt Tapia
  • Start date Start date
M

Matt Tapia

I have a dataset with one table and I want to find a specific row # or index
in that table where one of the columns (which contains a unique value) is
equal to a value I pass.

Any help?
 
One very easy way is to use the DataTable's DefaultView and then just set
the .RowFilter property to that value- it will then be the only row or
row(s) in your dataview. You can also use the .Select to find the row but
that doesn't return an index, it returns the row. One easy workaround is to
create a Datacolumn in the datatable and set its AutoIncrement property to
true. That way each row will now have an associated and properly indexed
value corresponding to its position in the table. You can do a
DataTable.Select and then just look at that column in the datarow - There's
also a .Find method that works similarly.

http://www.knowdotnet.com/articles/dataviewspart2.html This may help with
filtering and finding data.

HTH,

Bill

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
Hi Matt,

Why do you need index or row?
DataTable.Select method will return you one or more rows based on criteria
you pass.
You might also consider using DataTable.Rows.Find which will search using
primary key.
 
Back
Top