Set raddatepicker Calendar Focus to Today if DbSelectedDate =

4 posts, 0 answers
  1. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 17 May 2015 Link to this post

    I would like to set the raddatepicker calendar to today's date if the DbSelectedDate = "1/1/1900"

     Here is my control ASPX

     

    <telerik:RadDatePicker ID="rdp_ShipDate" runat="server" Culture="English (United States)"
        DbSelectedDate='<%#Bind("DateShipped")%>'
        SkipMinMaxDateValidationOnServer="True"  MinDate="1/1/1800 12:00:00 AM">
        <Calendar ID="Calendar1" runat="server" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False"
            ViewSelectorText="x">
            <SpecialDays>
                <telerik:RadCalendarDay Repeatable="Today" ItemStyle-BackColor="Green">
                </telerik:RadCalendarDay>
            </SpecialDays>
        </Calendar>
        <DatePopupButton HoverImageUrl="" ImageUrl="" />
    </telerik:RadDatePicker>

     

     Here is my attempted code behind

     

    Protected Sub fvw_OrderDetails_DataBound(sender As Object, e As System.EventArgs) Handles fvw_OrderDetails.DataBound
     
        If fvw_OrderDetails.CurrentMode = FormViewMode.Edit Then
            Dim DateShipped As RadDatePicker = DirectCast(fvw_OrderDetails.FindControl("rdp_ShipDate"), RadDatePicker)
            If DateShipped.DbSelectedDate = "1/1/1900" Then
                CType(fvw_OrderDetails.FindControl("rdp_ShipDate"), RadDatePicker).Calendar.FocusedDate = DateTime.Now
            End If
        End If
     
    End Sub

     Any help much appreciated.

     

     

     

  2. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 21 May 2015 Link to this post

    Hello Allan,

    You can achieve this requirement using the following approach:
    Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
        If e.Item.IsInEditMode Then
            Dim item As GridEditableItem = e.Item
            Dim picker As RadDatePicker = item.FindControl("rdp_ShipDate")
            If picker.SelectedDate = New Date(1900, 1, 1) Then
                picker.SelectedDate = DateTime.Now
            End If
        End If
    End Sub

    Hope this helps. Please give it a try and let me know if it works for you.

    You can also check the following section:
    ( Section Accessing controls in edit/insert mode )
    http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html


    Regards,
    Eyup
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Allan
    Allan avatar
    121 posts
    Member since:
    Jun 2008

    Posted 22 May 2015 in reply to Eyup Link to this post

    Thank you for the reply Eyup however this did not help. Here is my revised code:

     

     

    Protected Sub fvw_OrderDetails_DataBound(sender As Object, e As System.EventArgs) Handles fvw_OrderDetails.DataBound
     
        If fvw_OrderDetails.CurrentMode = FormViewMode.Edit Then
            Dim DateShipped As RadDatePicker = DirectCast(fvw_OrderDetails.FindControl("rdp_ShipDate"), RadDatePicker)
            If DateShipped.SelectedDate = New Date(1900, 1, 1) Then
                DateShipped.SelectedDate = DateTime.Now
            End If
        End If
     
    End Sub

     

    I is the popup calendar I am attempting to set to today's date not the actual selected date.

     

  5. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 22 May 2015 Link to this post

    Hi Allan,

    You can try to set the FocusedDate property to the picker.SharedCalendar control.

    If the issue remains, please prepare a new basic runnable web site demonstrating the problem and open a formal support to send it to us. Thus, we will be able to analyze and debug the project locally and try to come up with a viable solution for your case.

    Regards,
    Eyup
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top