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

Set raddatepicker Calendar Focus to Today if DbSelectedDate =

3 Answers 441 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 2
Allan asked on 17 May 2015, 05:33 PM

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.

 

 

 

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 21 May 2015, 07:28 AM
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
0
Allan
Top achievements
Rank 2
answered on 22 May 2015, 07:55 AM

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.

 

0
Eyup
Telerik team
answered on 22 May 2015, 04:35 PM
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
Tags
Calendar
Asked by
Allan
Top achievements
Rank 2
Answers by
Eyup
Telerik team
Allan
Top achievements
Rank 2
Share this question
or