Need to find the index of the particular value in datatable column

Hi All,

I have a scenerio where i need to find a particular value in a datatable column and if the value is found in the column i need to get the row index of that row from the datatable.
How can i acheive this …can anyone please help me to resolve this

Hi @vishal_nachankar

you can just use the LookUp DataTable Activity, provide the column you want to search the value, provide the value and datatable

Regards!

how can i get the index but and also i need to check the value is present or not if not present then it should not do the rest of the things

We do have several options

  • LookUp DataTable (as mentioned by Fernando)
  • Dictionary creation for lookup usage
  • LINQ

Assign Activity
myIndex =

myDataTableVar.AsEnumerable.toList.FindIndex(Function (x) x("ColNAmeOrIndex).toString.Equals("ABC"))

it will return the 0based index no. OR
-1 when not found

Hi @vishal_nachankar

Can you try this-

Assign activity:
rowIndex = -1

For Each Row activity:
For each row In DtOperacoes
If row(“ColumnName”).ToString() = “ValueToFind” Then
Assign activity:
rowIndex = DtOperacoes.Rows.IndexOf(row)
Break
End If
Next

Thanks!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.