public void initTurnGrid() { TurnsGrid.AutoGenerateColumns = false; if (PatientsGrid.Rows.Count > 0) { int id = int.Parse(PatientsGrid.Rows[int.Parse(PatientsGrid.CurrentCell.RowIndex.ToString())].Cells[0].Value.ToString()); TurnsGrid.DataSource = TurnRepository.GetPatientTurn(id).Select(T => new { Id = T.Id, Date = T.StartDate, DoctorName = 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; } }