|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 76
|
I have a date/time field in an sql database which the datepicker inserts into OK
I have edit page with the datepicker on so I need to populate it with the value from the database.
I'm using VS 2005
I tried: SelectedDates='<%# Bind("requestedDate") %>'
(requestedDate being the field in the database)
I get the following error:
Unable to cast object of type 'System.DateTime' to type 'EO.Web.DateCollection'.
What should I be using to bind the data to the datepicker?
Also, I've just realised that if I hard code the following: SelectedDates='2007-06-01' It displays that date as the default, but if I use the uk format:
SelectedDates='01-06-20071' It fails with: Cannot create an object of type 'EO.Web.DateCollection' from its string representation '01-06-2007' for the 'SelectedDates' property.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi Paul,
For the first quetion, please use SelectedDate instead of SelectedDates;
For the second question, yes, you do need to use the fixed format with SelectedDate or SelectedDates. You can use SelectedDateString. I believe that one uses the same format as your locale setting.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 76
|
Cheers! That worked but there is another problem.
In Visual studio I have this on an edit item template. If I select bindings from within VS and bind to my date field, This is what I get:
<eo:DatePicker ID="requiredDateTextBox" runat="server" DisabledDates="" Enabled='<%# Eval("requiredDate") %>' PickerFormat="dd/MM/yyyy" SelectedDates=""> </eo:DatePicker> As you can see, it has bound it to the enabled tag instead of the selecteddates tag.
This should read: <eo:DatePicker ID="requiredDateTextBox" runat="server" DisabledDates="" Enabled="true" PickerFormat="dd/MM/yyyy" SelectedDates="<%# Eval("requiredDate") %>"> </eo:DatePicker>
Which I then change to:
<eo:DatePicker ID="requiredDateTextBox" runat="server" DisabledDates="" Enabled="true" PickerFormat="dd/MM/yyyy" SelectedDateString="<%# Eval("requiredDate") %>"> </eo:DatePicker>
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi Paul,
We tried it at here and it does bind correctly. By default "Enabled" is selected when you first bring up the data binding dialog, if you don't change it but go directly to the data field box, you will end up getting your data field bound to Enabled property.
Please let us know if that is the case. If that is not the case, it would be much appreciated if you can provide specific steps to reproduce the problem.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 6/5/2007 Posts: 76
|
Ah! I see what you mean now.
Why can't it default to DateSelectedString?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi Paul,
I am not sure if we have any control over that. Visual Studo seems to have decided that "Enabled" is the most important property of the control. :(
Thanks
|
|