2
Answers

How to validate number in asending order in datatable column

Raja

Raja

8y
198
1
in data table particular column is have only ascending order numbers.this is strictly start from 1,2,3,4,5
 
i validate unique of the column but now i want to validate only start from 1 and ascending order if
data table row have 10 rows the number is 1,2,3,4,5,6,7,8,9,10. how to do it.
 
if (ds.Tables[s].Rows[2][2].ToString().Trim() == "")
{

}

This is my code for validate empty rows .please find the attachment 
Answers (2)
1
Midhun T P

Midhun T P

NA 19.7k 281.1k 8y
Hi,
 
If you need the data in the order 1,2,3,etc.. without any gap between numbers, then you can try below code -
 
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i]["Your column"].ToString() != (i + 1).ToString())
{
//The order is incorrect
}
}
 
Accepted
0
Raja

Raja

NA 1.7k 45.4k 8y
Sorry For late Reply.
Thank You!
 

Midhun T P