How to get the row number from a datatable? March 25, 2023 by Tarik int index = dt.Rows.IndexOf(row); But you’re probably better off using a for loop instead of foreach.