How Can I check Item exist in LIST<DataRow> in Uipath

datatable

#1

Hi Folks,

How Can I check Item exist in LIST ?

Regards,

Ganesh A


#2

@ganeshatkale

1.Suppose if you are having a list of strings list a
2. you want check whether strb is present in list or not
3.use one assign activity
4. bool a = list a.Contains(strb) use this in assign activity
5. if bool a=true then strb is present in the list
6. if bool a= false then strb is not present in list

Regards,
Mahesh


#3

Hi @ganeshatkale,
Use if activity to check the item existed in the list ot not
list.contains(item)

Regards,
Arivu :slight_smile:


#4

Hi,

If this is a list or array of datarows from a datatable, and you are looking at the columns/items of the datarow, then I would normally use the .IndexOf method.

Here are some examples

For each row In list<datarow>
    if Array.IndexOf( row.ItemArray, "text" ) > -1

The above will loop through each row and see if a word exists in the row with ItemArray to convert all the columns to an array of the items in that row.

You can also use the IndexOf with datatables, like dt.Rows.IndexOf( row ) > -1

I apologize if I get syntax wrong or misunderstand your goal.

Regards.