Removing multiple rows from data table


#1

Hi,

I want to remove multiple rows from a data table. For example lets say I am having datatable DT1 and I have to remove 2nd, 4th and 5th row from it. Could anyone please advise what’s the best way to achieve same.

Thanks,
Kapil


#2

Hi Kapil,

Are you checking for any condition in the row value and then removing the rows or directly you will decide on from which index the row should be deleted?

If its based on condition, (variables are specified in bold)

  • use select query to apply the condition on datatable, DT1 and get the output as array of datarow, arDataRow
  • Loop through arDataRow and check index of each row in DT1,
    index = DT1.Rows.indexOf(row)
  • To remove the row, Use Remove data row activity and in properties specify Datatable as DT1, RowIndex as index
  • Continue the loop until all array items are processed from arDataRow

If you don’t need to apply and conditions and just want to remove from the known indexes,
Use Remove data row activity and in properties specify Datatable as DT1, RowIndex as index from your list.

Hope this helps!