private void Edit_InKindService(object sender, MouseButtonEventArgs e) { try { DataGrid dg = sender as DataGrid; InKindService p = (InKindService)dg.SelectedItems[0]; // OR: Patient p = (Patient)dg.SelectedItem; UpdateInKindService up = new UpdateInKindService(p); up.DateRecieved.SelectedDate = p.StartDateTime; if (p.StartDateTime.Hour >= 12) { up.AMPM_Start.SelectedIndex = 1; } else { up.AMPM_Start.SelectedIndex = 0; } if (p.EndDateTime.Hour >= 12) { up.AMPM_End.SelectedIndex = 1; } else { up.AMPM_End.SelectedIndex = 0; } up.ShowDialog(); } catch (Exception error) { } Refresh_InKindServiceGrid(sender, e); }