i want to retrive min and max value from dataset and those values use in for loop for display title in panel
String sql = \"select title, song_id from up_so
Make use of LINQ:
var m = ds.Tables["title"].AsEnumerable().Max(x => x.Field<int>("song_id"));
var k = ds.Tables["title"].AsEnumerable().Min(x => x.Field<int>("song_id"));
Remeber that you have to add System.Data.DataSetExtensions
to have DataSet.AsEnumerable()
extension :)
var maxTwn = mydataset.Tables[0].AsEnumerable().Max(r =>r["TWN"]);
var minTwn = mydataset.Tables[0].AsEnumerable().Min(r =>r["TWN"]);
With using Linq
extension methods:
int minSongId = ds.Tables["title"].AsEnumerable()
.Min(r => r.Field<int>("song_id"));
int maxSongId = ds.Tables["title"].AsEnumerable()
.Max(r => r.Field<int>("song_id"));
What about using this?
foreach(DataRow row in ds.Tables["title"].AsEnumerable())
{
....
}