Search Datatable and write in it if found

Hi All,
I have a doubt about data-table.
Let us think I have a data table dt1
Now I want to search the dt1 for a “sample_string” if found I should write something in the next cell.
Can any one help with out for each.
Thanks in advance.


1.If you want to search the dt1 for a “sample_string” ,use if condition inside the for each loop
dt1.Contains(“sample_string”) // if this condition is true
then store your values


Hi Sob,

Thanks for immediate response, I don’t want to use for each, I have to achieve with .select method and once found I need to write in it.


If your excel file contains more than 1 row , then either we have to use for each or while loop.

If you can please elaborate your requirements.

1 Like

Okay let me explain,
I need to search for a specific invoice number in the datatbale dt1 which has 5 columns and 1st column is Invoice. If I find the invoice in the first column then I need to write the status in 5th column. Also I know that I can search my dt1 by using .select method but I dont know how to write inside the dt1 once found.

Hi @harinred

is there any reason why you can’t use for each row ?

its harder to do what you want without it. It requires more activities and more logic.



I believe you can achieve this with Select method. If this is what you are looking for,

Use Assign Activity as below:
dtRowArray = dtTable.Select(“Your Query”)

where dtRowArray is your DataRow & dtTable is the DataTable.

For your reference,

Rammohan B.

1 Like

Hi Pablo,
Thanks for the quick response. But I assume that for each needs more steps than .select method and for each is more time consuming compared to .select. Correct me if I am wrong.

@harinred I belive that For each row with 5 columns won’t take so much time… if you arent able to make it with select activity, try this and check the time it spend processing.


1 Like

Hi Ram,

First of all I would like to thank all of you guys for sparing time.

This is not exactly what I am looking for.
I know that“string”) will return us full datarow where that string is present.( Correct me if I am wrong)
Once I receive that datarow how can I write inside that row ?
Let me know if I cannot achieve this using select then I use for each Method.

Have you tried this?:

datarow(“Name of the column”) = Your new value ; I’m not sure 100% if that will work when you are in a datarow… That works in for each row, taking datarow as type of argument… but outside of that activity i dont know how it will act

1 Like

You can write inside the DataRow like this within an Assign Activity,
dtRowArray(0).Item(1) = “Status”, but unfortunately this will be an independent DataRow and won’t be updated in your existing DataTable. You may have to Add this row in your existing or new DataTable.

I don’t see a way to directly update this DataRow into a matched position in your existing datatable. Not sure if there is any such method that does exist which i may not be aware of. :slight_smile:

Rammohan B.

1 Like

Hi Ram,
Thanks for the advice, then I use for each only.
Once again thank you all.

No bro that will not work outside the for each.