How to get the RowIndex from Datatable ?

In our daily automation we are mostly dealing with the one of the most used datatype which is DataTable, here we will see how we can get the row index of a particular row based on some conditions from the datatable.

Let’s see how to do it.

Example 2

Let say we have a datatable below and from that we want to get the row index of the row where col Name is having the value Virat

image

Step 1:
Create avariable of type Integer var = Index

Step 2:
Take one assign activity:
LeftSide = Index
RightSide=dt.Rows.IndexOf(dt.AsEnumerable().Where(Function(x) x(“Name”).ToString.Equals(“Virat”)).ToArray.First)

image

This example will give us the Index of First occurrence of the row

I hope you enjoyed the article!!

3 Likes

Idx=DT.Asenumerable.Tolist.Findindex(Function(r) r(Column_Name).Tostring.equals(YourString))

1 Like