Autonumber column in datatable based on number of rows

Hi @Evert_Randers

How about this expression?

dataTable.Columns.Add("ID", GetType(Integer))
For i As Integer = 0 To dataTable.Rows.Count - 1
dataTable.Rows(i).Item("ID") = i + 1
Next

This will add a new column named “ID” to your DataTable and fill it with numbers starting from 1 .

You can also use an Auto-Number System column to generate an automatically incremented counter for each row that contains data

Check out the thread

Regards
Gokul