protected void EmpSC_Click(object sender, EventArgs e) { EmployeeSpDataSet dataset = new EmployeeSpDataSet(); var AllEmp = _service.GetAllEmployeeDuty().OrderByDescending(x => x.EndDate).GroupBy(x => x.Employee_Id).Select(x => x.First()).Take(3).ToList(); if (AllEmp != null) { for (int i = 1; i <= 3; i++) { var empsp = AllEmp.FirstOrDefault(); var emp = _service.GetAllEmployee().Where(x => x.Id == empsp.Employee_Id).FirstOrDefault(); dataset.EmployeeScpass.Rows.Add(emp.Id, emp.Name, emp.Cnic, empsp.ToSectorName, emp.ImgBody ); AllEmp.Remove(empsp); } }