/// <summary> /// This method binds the coach dropdown by getting all the coaches in /// the program that were active at the point of time passed to this method. /// </summary> /// <param name="logDate">The date and time to check against</param> /// <param name="programFK">The program FK</param> /// <param name="coachFK">The coach's FK to be selected</param> private void BindCoachDropDown(DateTime?logDate, int programFK, int?coachFK) { if (logDate.HasValue) { using (PyramidContext context = new PyramidContext()) { //Get all the coaches in the program that were active as of the log date var allCoaches = context.spGetAllCoaches(programFK, logDate).ToList(); //Bind the coach dropdown to the list of coaches ddCoach.DataSource = allCoaches; ddCoach.DataBind(); } //Try to select the coach passed to this method ddCoach.SelectedItem = ddCoach.Items.FindByValue(coachFK); //Enable the coach dropdown ddCoach.ReadOnly = false; } else { //No date was passed, clear and disable the coach dropdown ddCoach.Value = ""; ddCoach.ReadOnly = true; } }