Is there any way to insert value into the first row of an existing datatable?
For Example.
1 Red
2 Blue
3 Green
but i want to insert a new row on top of 1. So the End result is
99 Black
1 Red
2 Blue
3 Green
Is there any way to insert value into the first row of an existing datatable?
For Example.
1 Red
2 Blue
3 Green
but i want to insert a new row on top of 1. So the End result is
99 Black
1 Red
2 Blue
3 Green
Hi @zhongyong11
Yes there is
It uses Invoke Method activity to do the job.
Please see attached project for reference:
InertNewRowAtTheTop.zip (10.5 KB)
Hi @zhongyong11
Yes, there indeed is.
Youâll have to do something like this: dtTable.Rows.InsertAt(drRow,intPos); where âdrRowâ is the row you want to insert and âintPosâ is the position at which you want to enter the row.
NOTE: This code doesnât return any value and just modifies the data table. Hence, use the activity âInvoke Codeâ and write this code inside it. I think @loginerror must have done the same thing, though I havenât seen his code.
Thanks for the example. is it possible to modify it so that it is able to insert into an existing datatable without using the build datatable activity?
Absolutely, I only did that so I can provide you with a working example. You can essentially only look at the Invoke Method activity and replace the variable names with yours ![]()
i tried it, i replaced your datatable variable name with my Datatable name, and deleted the build datatable activity, but i couldnt get any output afterwards.
Check if you have any data inside the datatable variable. The value of the datatable might be null. To check that, either debug your process or use output datatable to check what value youâre getting.
Edit: Could you upload your workflow here for people to see? We may be able to understand your issue better that way.
thanks guys. IT WORKS NOW :DDD THANKSSSSSS
TrackerStorage.Rows.InsertAt(row, temp); I tried this but itâs not working.
I will appreciate your help on this. I am trying to insert a row in a specific row of exel file.