Welcome Guest Search | Active Topics | Sign In | Register

Datepicker - populate from database Options
Paul Creedy
Posted: Friday, June 15, 2007 7:29:20 AM
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.



eo_support
Posted: Friday, June 15, 2007 1:16:39 PM
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
Paul Creedy
Posted: Monday, June 18, 2007 12:55:48 AM
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>
eo_support
Posted: Monday, June 18, 2007 7:50:01 AM
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
Paul Creedy
Posted: Monday, June 18, 2007 7:59:18 AM
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?
eo_support
Posted: Monday, June 18, 2007 8:05:25 AM
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


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.