find min and max values in a datatable using C# -
possible duplicate:
how select min , max values of column in datatable?
i searching code find min , max (or first , last values) column in datatable.
i have stored datatable 4 column values want find min , max values third column(index 2) , display user.
i tried many ways causing exceptions...
last tried code not working..
count = convert.toint32(dt.rows.count); start = convert.toint32(dt.rows[0][2].tostring()); end = convert.toint32(dt.rows[count-1][2].tostring());
thanks vince
you use .select
method on datatable
rows:
var maxrow = dt.select("id = max(id)");
this return datarow[]
array - should typically contain single row (unless have multiple rows same, maximum value).
same goes minimum:
var minrow = dt.select("id = min(id)");
see msdn docs on datatable.select
more details.
Comments
Post a Comment