This is a migrated thread and some comments may be shown as answers.

Update asp:DetailsView which uses RadDateTimePicker

2 Answers 73 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Reem Reem
Top achievements
Rank 1
Reem Reem asked on 22 Feb 2010, 02:24 PM
Hi,

I need your help, pleas.. I'm trying  to edit some fields in my detailsview and it works fine except the RadDateTimePicker.
I used it in the EditItemTemplate as below:

<asp:TemplateField HeaderText="IN">  
                <EditItemTemplate>  
                    <telerik:RadDateTimePicker ID="RadDateTimePicker1" Runat="server"   
                        AutoPostBackControl='<%# bind("CHECKIN") %>' Culture="English (United States)"   
                        Enabled='<%# bind("CHECKIN") %>' SharedCalendar='<%# bind("CHECKIN") %>'   
                        SharedTimeView='<%# bind("CHECKIN") %>' Visible='<%# bind("CHECKIN") %>' >  
                         
                    </telerik:RadDateTimePicker>  
                </EditItemTemplate>  
                 
                <ItemTemplate>  
                    <asp:Label ID="Label1" runat="server" Text='<%# eval("CHECKIN") %>' DataFormatString="{0:MM/DD/YYYY HH:MI:SS AM}"  
                    HtmlEncode="false">  
                    </asp:Label>  
                </ItemTemplate>  
                  
            </asp:TemplateField>  

and i get this error:
System.InvalidCastException: Conversion from type 'Date' to type 'Integer' isnot valid.

i tried to solve this by many ways but all of them didn't work

I think the problem is in the data binding method but i couldn't find the correct format?

I appreciate your reply, Thanks 

2 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 25 Feb 2010, 10:34 AM
Hello Reem,

The RadDateTimePicker.Enabled and RadDateTimePicker.Visible properties are of Boolean type. So you could not set to them values which is of DateTime type. To avoid the error and bind the RadDateTimePicker to the database value I suggest you to use the following code snippet:

<EditItemTemplate>
  <telerik:RadDateTimePicker ID="picker1" runat="server" DbSelectedDate='<%# Bind("CHECKIN ") %>'>
  </telerik:RadDateTimePicker>
</EditItemTemplate>

Also you could check out the following online example which demonstrates binding the RadDateTimePicker control:


http://demos.telerik.com/aspnet-ajax/calendar/examples/datetimepicker/databinding/defaultcs.aspx

I hope this helps.

Kind regards,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Reem Reem
Top achievements
Rank 1
answered on 27 Feb 2010, 08:40 AM
thank you very much for your help, it works fine now :)
Tags
Calendar
Asked by
Reem Reem
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Reem Reem
Top achievements
Rank 1
Share this question
or