I have two columns in a datatable:
ID, Calls.
How do I find what the value of Calls is where ID = 5
?
5 could be anynu
You can use LINQ to DataSet/DataTable
var rows = dt.AsEnumerable()
.Where(r=> r.Field("ID") == 5);
Since each row has a unique ID, you should use Single/SingleOrDefault
which would throw exception if you get multiple records back.
DataRow dr = dt.AsEnumerable()
.SingleOrDefault(r=> r.Field("ID") == 5);
(Substitute int
for the type of your ID field)