How to store a dataRow from a datatable?

I want to create a new datatable from a given original datatable but updating each row with some new values.
While looping through the original datatable, how do I store the current row in some new temporary row and make changes to that temporary row and save it to new datatable??

Right now, while using “Assign” acitivity to save current datarow and making changes in it also changes the original datarow.

How do I save current datarow so that making changes to new datarow doesnt affect the original datarow??

Hi @Ayush_Raj,

You can assign the dataRow from your For Each Row to another dataRow variable:

YourNewDataRow = YourDataRow

I am trying this, but it is also updating my original row

Could you please attach a screenshot of your For Each Row? I would’ve thought that wouldn’t be possible as it is a new variable…

you can do it in several ways
try this
1- add new column to your table
2- looping in your table and save the values you want to the new column
3- use filter activity to your table and type the name of column you want in output

Hi @Ayush_Raj


  • DataTable newDataTable = new DataTable()

For Each Row: Iterate through originalDataTable

  • Assign:
    • DataRow newRow = newDataTable.NewRow()
    • newRow.ItemArray = row.ItemArray.Clone()
    • newRow(“ColumnName”) = “New Value”
  • Add DataRow:
    • DataTable: newDataTable
    • Row: newRow

Hope it helps!!

Hi @Ayush_Raj

You can use two read range workbook activities to read the excel and store it in two datatable variables.
Make one as Originaldatatable and duplicatedatatable.
You can use the Originaldatatable to take the input and use the duplicate one to modify the rows.

You can iterate the values of Original datatable and make the changes in duplicate datatable.
If you want to remove all the rows and stay the columns same in the duplicate datatable. Use the Clear Datatable activity.

Hope it helps!!

Assign Activity:
dtNew = dtOld.Clone

For each row Activity | row in dtOld

  • Assign Activity| tmpRow = dtNew.NewRow
  • Assign Activity| tmpRow.ItemArray = row.ItemArray
  • Do your updates on tmpRow
  • Add Data Row Activity : DataRow - tmpRow, DataTable - dtnew
1 Like

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