Update a Datatable row values based on condition

I have a Datatable with 3 columns,
Name, account number and status.
A name can have multiple account numbers, and if i process any one of the account number of a user, then the status should be set to completed or failed, based on what the process returns.

Things i have done till now.
Outer loop Name:

  • Get all the account numbers associated with that Name
  • Inner loop Account numbers are looped
    • Process is executed and clicked save
      It returns either Completed or failed.
      Now i want to update the all the account numbers associated with that user as completed or failed
      ** I am stuck here**
      once this is done go to the next name.

Save the updated Datatable to an excel.

Thank you

We could think about:

  • Grouping the data by Name
  • Process all groupmembers
  • When any member of a group fails, then set the status to all

We recommend to work on Datarow levels eg Groups = List(Of List(Of DataRow)) as a heavy CopyToDataTable will get lost the origin DataTable Identities

Assign Activity:
Groups | List(Of List(Of DataRow)) =

(From d in yourDataTableVar.AsEnumerable
Group d by k=d("Name").ToString.Trim into grp=Group
Select g = grp.ToList).ToList

For each Activity | grp in Groups | TypeArgument: List(Of DataRow)

  • For each Activity | mbr = gpr | TypeArgument: DataRow
    • Process the members (e.g. Account number), track the status and break innerloop by issues
  • For each Activity | mbr2 = gpr | TypeArgument: DataRow
    • Set the status to all members from the group