Hello @abdel,
The error is because you are trying to get the more number of rows than the datatable have which is not possible hence you are getting the error as index out of bound or range, buy using the method dt.Rows.Count you can get how many number of rows are there in that datatable.
Thanks,
Sanjit