public void initTurnGrid() { if (DoctorsGrid.Rows.Count > 0) { TurnsGrid.AutoGenerateColumns = false; int id = int.Parse(DoctorsGrid.Rows[int.Parse(DoctorsGrid.CurrentCell.RowIndex.ToString())].Cells[0].Value.ToString()); TurnsGrid.DataSource = null; TurnsGrid.DataSource = turnRepository.GetDoctorTurn(id, ClinicId).Select(T => new { Id = T.Id, Date = T.StartDate, PatientName = T.doctor.People.Name + " " + T.doctor.People.Family, Type = T.TurnType.Name, IsPaid = T.IsPaid, TurnPrice = T.TurnType.Price }).ToList(); if (TurnsGrid.Rows.Count > 0) { TurnsGrid.CurrentCell = TurnsGrid[0, 0]; } } else { TurnsGrid.DataSource = null; } }