How to create a column with batch number in a datatable

Dear Developers, i have a table with over 400++ line items…i want to create a column named “Batch” and write batch number by number of rows. first 100 rows is for batch 1, next 200 belongs to batch 2… and so forth. Kindly need your expertise. really appreciate a method which does not use for each row as it might be time consuming. Thank you in advance,


Can you try the following sample?


dt = dt.AsEnumerable.Select(
    r("Batch")=1+(i \ 100)
    Return r
End Function
).CopyToDataTable (2.7 KB)


1 Like

dear @Yoichi , this works just perfect. thank you so much for your fast response

1 Like

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