public override void PopulateData() { try { int idx = 0; int val = 0; int driverTypeId = optRent.Checked ? Enums.DRIVERTYPES.RENT : Enums.DRIVERTYPES.COMMISSION; using (TaxiDataContext db = new TaxiDataContext()) { var list = (from a in db.stp_DriverPaymentAccountBookings(driverTypeId, numrent.Value.ToDecimal()) select new { a.Id, a.TransId, a.Active, a.AccountBookings, a.TotalRentCommission, a.ActualTotalRentCommission, a.DriverName, a.DriverNo, a.DriverToPay, a.OfficeToPay, a.PreviousBalance, IsPaid = a.IsWeeklyPaid, Paid = a.IsWeeklyPaid != null && a.IsWeeklyPaid == true ? "Paid" : "", a.FromDate, a.ToDate, PaidValue = a.IsWeeklyPaid != null && a.IsWeeklyPaid == true ? 1 : 0 }).ToList(); var list2 = (list.AsEnumerable().OrderBy(item => item.DriverNo, new NaturalSortComparer <string>())).ToList(); idx = grdLister.CurrentRow != null ? grdLister.CurrentRow.Cells["Id"].Value.ToInt() : -1; val = grdLister.TableElement.VScrollBar.Value; grdLister.BeginUpdate(); grdLister.RowCount = list2.Count; for (int i = 0; i < list2.Count; i++) { grdLister.Rows[i].Cells["Id"].Value = list2[i].Id; grdLister.Rows[i].Cells["TransId"].Value = list2[i].TransId; grdLister.Rows[i].Cells["Active"].Value = list2[i].Active; grdLister.Rows[i].Cells["DriverNo"].Value = list2[i].DriverNo; grdLister.Rows[i].Cells["AccountBookings"].Value = list2[i].AccountBookings; grdLister.Rows[i].Cells["PaidAccountBookings"].Value = list2[i].IsPaid.ToBool() ? list2[i].AccountBookings : 0.00m; grdLister.Rows[i].Cells["TotalRentCommission"].Value = list2[i].TotalRentCommission; grdLister.Rows[i].Cells["PaidTotalRentCommission"].Value = list2[i].IsPaid.ToBool() ? list2[i].TotalRentCommission : 0.00m; grdLister.Rows[i].Cells["ActualTotalRentCommission"].Value = list2[i].ActualTotalRentCommission; grdLister.Rows[i].Cells["OfficeToPay"].Value = list2[i].OfficeToPay; grdLister.Rows[i].Cells["PaidOfficeToPay"].Value = list2[i].IsPaid.ToBool() ? list2[i].OfficeToPay : 0.00m; grdLister.Rows[i].Cells["DriverToPay"].Value = list2[i].DriverToPay; grdLister.Rows[i].Cells["PaidDriverToPay"].Value = list2[i].IsPaid.ToBool() ? list2[i].DriverToPay : 0.00m; grdLister.Rows[i].Cells["PreviousBalance"].Value = list2[i].PreviousBalance.ToDecimal(); grdLister.Rows[i].Cells["PaidPreviousBalance"].Value = list2[i].IsPaid.ToBool() && list2[i].PreviousBalance.ToDecimal() < 0 ? list2[i].PreviousBalance.ToDecimal() : 0.00m; grdLister.Rows[i].Cells["IsPaid"].Value = list2[i].IsPaid.ToBool(); grdLister.Rows[i].Cells["Paid"].Value = list2[i].Paid.ToStr(); grdLister.Rows[i].Cells["FromDate"].Value = list2[i].FromDate.ToDate(); grdLister.Rows[i].Cells["ToDate"].Value = list2[i].ToDate.ToDate(); grdLister.Rows[i].Cells["PaidValue"].Value = list2[i].PaidValue.ToInt(); } grdLister.EndUpdate(); } SetDefaultColumnSettings(); AddSummaries(); UpdatePeriod(); if (idx > 0) { grdLister.CurrentRow = grdLister.Rows.FirstOrDefault(c => c.Cells["Id"].Value.ToInt() == idx); } if (grdLister.TableElement.VScrollBar.Maximum >= val) { grdLister.TableElement.VScrollBar.Value = val; } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }