private void DG5_SelectionChanged(object sender, SelectionChangedEventArgs e) { PlannerClass.ContractsPerTicket.Clear(); foreach (FC_TripTicket_WProgress c in DG5.SelectedItems) { PlannerClass.ContractsPerTicket = PlannerClass.ContractsPerTicket_Populate(c.instance); foreach (FC_LocalContract x in PlannerClass.ContractsPerTicket) { string query = "select * from FC_TripTicketLine where FC_TripTicketID = " + c.instance.FC_TripTicketID.ToString() + " and FC_LocalContractID = " + x.FC_LocalContractID.ToString() + " ;"; FC_TripTicketLine t = new FC_TripTicketLine(); List <FC_TripTicketLine> theTicketLine = t.ObjToTable(SQL.Select(t, query)); x.Quantity = theTicketLine[0].PalletsOnTicket; } PlannerClass.RoutSegsPerTicket_Populate(c.instance); } DG6.ItemsSource = null; DG6.ItemsSource = PlannerClass.ContractsPerTicket; DG7.ItemsSource = null; DG7.ItemsSource = PlannerClass.RouteSegsPerTicket; }