generates a random number between start and end values. Now lets suppose your datatable has 3 rows and look at your code:
int cnt = dt.Rows.Count + 1;for (int i = 0; i < dt.Rows.Count; i++)
rn = rand.Next(1, cnt);}
Running this code 3 times there is a fair possibility that you will get repeated value. Now its up to you how do you generate a random number. Can you tell us what exactly is the requirement? If this unique number has anything to do with database you might have an idea about identity value.