I'm trying to use the calendar control to pick out a date for a doc appointment and when doctors are unavailable the dates are blacked out so you can't select them. The blacking out works perfectly but when it changes selected doctor the blacked out dates stack so it limits the available days for doctors that have been selected after another doctor.
I'm Trying To Do This In a WPF App
This is the code I use to blackout the dates:
DocAvail da = new DocAvail();
DataTable dt;
// GetAvailability() just runs an SQL statement selected the days that the doctor isn't
// available and returns it in a DataTable
dt = da.GetAvailability(docID);
foreach (DataRow dr in dt.Rows) {
for (DateTime day = min; day <= max; day = day.AddDays(1)) {
if (day.DayOfWeek.ToString() == dr["nameofDay"].ToString()) {
calAppointment.BlackoutDates.Add(new CalendarDateRange(day));
}
}
}
Im Stupid, This Works: calAppointment.BlackoutDates.Clear();