Update asp:DetailsView which uses RadDateTimePicker

3 posts, 0 answers
  1. Reem Reem
    Reem Reem avatar
    2 posts
    Member since:
    Feb 2010

    Posted 22 Feb 2010 Link to this post

    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. Radoslav
    Admin
    Radoslav avatar
    1566 posts

    Posted 25 Feb 2010 Link to this post

    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.
  3. Reem Reem
    Reem Reem avatar
    2 posts
    Member since:
    Feb 2010

    Posted 27 Feb 2010 Link to this post

    thank you very much for your help, it works fine now :)
Back to Top