Asking for a better way of Dividing Datable and Looping in them

Hi @Archie

We can split the datatable into two dt like this

For rows containing only Foreign

Dt1 = Maindt.AsEnumerable().Where(Function(a) a.Field(of String)(“yourcolumnname”).ToString.Contains(“Foreign”)).CopyToDatatable()

For rows containing only Local

Dt2 = Maindt.AsEnumerable().Where(Function(a) a.Field(of String)(“yourcolumnname”).ToString.Contains(“Local”)).CopyToDatatable()

This will Dt1 and Dt2 with which you can now use a for each loop based on your process

Where Dt1 and Dt2 are datatable variable defined in Variable Pabel with default value as New System.Data.Datatable

Hope this would help you resolve this issue

Cheers @Archie

1 Like