Working with Datarow

i have a data table, i have a specific value to be searched, when found i want to perform following Actions:

  1. copy the values of the total ROW and paste it in specific place
  2. delete the Particular row from the data table how can i achieve this.

@devasaiprasad_K

  1. Use filter datatable and check if any row is returned
  2. If returned value is present …then use filter now again but now select the opossite so that the row you need is removed and all other rows are remaining
  3. If you need that row in another table then use add data row and use itemarray to populate data

cheers

Hi @devasaiprasad_K

rowToCopy = (From row In inputDT.AsEnumerable()
             Where row("ColumnName").ToString() = specificValue
             Select row).FirstOrDefault()
outputDT = (From row In inputDT.AsEnumerable()
            Where row("ColumnName").ToString() <> specificValue
            Select row).CopyToDataTable()

Regards,

maybe you can define more in detail what is meant by

it depends on your needs / strategies

  • when, only the filter result is needed, then go for any filter approach and use the new resulting datatable
  • when the identity of the origing datatable is to keep and the rows are to remove from there, then
    • grab the rows / row indexes which are to remove
    • remove the rows e.g by activity or code

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