Hi,
Say I have DT1
I am filtering the DT1 with some conditions, and getting DT2Filtered.
Now, I am trying to find the row number in DT1 with row values from DT2Filtered. But I am getting row number as -1 for all rows.

Inside For each Row activity,
For Each row in DT2Filtered
Rowindex = DT1.Rows.IndexOf(row)

Here I am getting -1 for RowIndex for all the rows supplied. please advise.

Hi @vigneshnkv
In your example row refers to the DataRow objects of DT2Filtered, thus searching for it’s rowindex in DT1 is returning -1. A simpler solution would be to have a primary key or a column that contains unique values for every row and using that to find connections between the 2 datatables.

If this is not an option, then can you share more details regarding your requirement?

Filter with some conditions, this will reduce the no of rows (DT2Filtered)

take the values of Column “C” and compare with another Excel2’s Column “C” (say I have as DT3).

If matches, then mark the Status as “pass” in Excel1 (DT1). to mark this, I need to find the correct row (from DT1). So I am trying to get the row index as mentioned above. Please suggest if there is any option for this.

hi @vigneshnkv
One solution would be to just add an Index column to DT2Filtered table which stores the index of the row respective to DT1 table.
Then you can use that index to find the row in DT1 after comparison with DT3.
I have attached an example of this solution.

If you are using DataTable.Select() method initially to get the filtered data you don’t have to use the index column strategy, since you won’t be needing DT2Filtered table.