I just noticed something weird about the calendar control in ASPNET2. If you assign a value to SelectedDate that has a time
component (e.g., 3/1/2007 10:37 AM), and you have a custom style for the selected day, the selected day will not be rendered using
the custom style. Instead, the control acts like >>no<< date has been selected.
I came across this when doing a SelectedDate='<%# Bind("date_field") %>', where the date_field is a datetime sql server field.
There's an obvious workaround -- use ((DateTime) Eval("date_field")).Date instead of the Bind expression -- but then you have to add
code to extract the value before, say, doing an update against the database, since you've lost the databinding (and Bind() does not
return a value; it binds values).
Of course, an even better workaround would be for the silly control to work right in the first place, and recognize that a
SelectedDate of 3/1/2007 10:37 AM is, in the context of a >>calendar<< equivalent to 3/1/2007 12:00 AM and should be treated as such
for purposes of deciding when to render using the SelectedDay style.
- Mark