var dt = GridView1.DataSource as DataTable;
var a= dt.AsEnumerable().GroupBy(s => s.Field<string>("Discipline").ToString());
//dt.DefaultView.Sort = sort;
var final = dt.AsEnumerable().GroupBy(x => x.Field<string>("Discipline"), (key, g) => g.OrderByDescending(s => s.Field<Int64>("ID")).First()).Select(t=>t.Field<Int64>("ID"));
var tt = final.ToList();
if(tt.Exists(o=> o == Convert.ToInt64(DataBinder.Eval(e.Row.DataItem, "ID"))))
{
e.Row.BackColor = System.Drawing.ColorTranslator.FromHtml("#0000ff");
}
reference:-https://stackoverflow.com/questions/35170408/linq-how-to-get-the-max-id-with-a-group-by-clause
No comments:
Post a Comment