imran azam

imran azam

  • NA
  • 98
  • 12.9k

Select record between two column from DataTable.

Apr 21 2016 1:11 AM
Hi Members,
I have searched on Google but didn't find any solution pls anyone help me out.
 
Problem: I have three Column ID,Value1,Value2 in the Datatable.
DataTable is looking like this : 
ID    Value1    Value2
1      10            20
2      15            30 
 
I want to find the data  between range means let's say in example :
 
if i enter 15 to 30 it should not allow because 15 is already present between 10 to 20.
 
This is the code i have written if i enter same value again then i will get message:
 
if (dtCurrentTable.AsEnumerable().Any(row =>Convert.ToInt32(drCurrentRow["Value1"]) == row.Field<Int32>("Value1") &&Convert.ToInt32(drCurrentRow["Value2"]) == row.Field<Int32>("Value2")))
{
//msg
}
 
So, How to write Code to achieve my task as i explain above.
 
 

Answers (3)