My telescope observatory app has a varying DayBeginsHour, depending on the season. In the summer, the sun sets closer to 9 pm, and in the winter, closer to 5 pm. I'm trying to get the app to allow me to dynamically alter the hours based on the season, and having mixed success.
I'm in Resources view mode, and trying to alter the hours during the column reconstruction, which happens on every callback, and in particular whenever the date in the navigator changes:
private void BuildColumns()
// seasonally adjust business hours here.
ObservatorySite.Location site = GetSiteFromCookie(ReservationsPilot.StartDate);
theSun = SunInfo.CalculateSunPosition(ReservationsPilot.StartDate, site, true);
ReservationsPilot.DayBeginsHour = theSun.SunSet.AddMinutes(-40).Hour;
ReservationsPilot.DayEndsHour = theSun.SunRise.AddHours(2).Hour;
ReservationsPilot.BusinessBeginsHour = ReservationsPilot.DayBeginsHour;
ReservationsPilot.BusinessEndsHour = ReservationsPilot.DayEndsHour;
for (int i = 0; i < ReservationsPilot.Days; i++)
DateTime dateSelected = ReservationsPilot.StartDate.AddDays(i);
Column c = new Column(dateSelected.ToLongDateString(), "Date");
c.Date = dateSelected;
Column resCol = new Column("Reservations", "Customer");
resCol.Date = dateSelected;
Column astroCol = new Column("Sun / Moon", "System");
astroCol.Date = dateSelected;
That function is called immediately before every DataBind call, so that should work.... and mostly does.
The problem is the events aren't following suit. When it is time to add an extra hour to the view (sunset is earlier), it does so... but the events do NOT move to their new homes. The events then become "orphaned" an hour away from their true home.
I also tried using the UpdatePanel method you glossed over in that answer, and could not get it to work.
Can you provide a more complete code example of how one could do this? Thanks!