Any way to set default display date for a RadDatePicker column as today's date?

3 posts, 0 answers
  1. Dexter
    Dexter avatar
    34 posts
    Member since:
    Dec 2012

    Posted 29 Apr 2014 Link to this post

    As per title, when I click to add a new row in my RadGridView, I would like my RadDatePicker column to auto display today's date rather than 1/1/0001.
    Is there any way to do this? I've tried to set various properties at design time such as DisplayDate, DateTextTime, SelectedDate but all doesn't make a difference.

    I would perhaps try to do it at code-behind rather than design time, but I have no idea how to access it.
    Anyways here are my codes currently:

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=SvcDate}" UniqueName="SvcDate"
                                                TextWrapping="Wrap" Width="100" TextAlignment="Center" DataFormatString="{}{0:ddMMyy}">
                            <TextBlock Text="Service Date" TextAlignment="Center"/>
                                <telerik:RadDatePicker SelectedValue="{Binding Path=SvcDate}"
                                                       ErrorTooltipContent="Unrecognised format. Use drop-down interface for input assistance."
                                                       Culture="en-SG" DisplayDateStart="01/01/2014">

  2. Dexter
    Dexter avatar
    34 posts
    Member since:
    Dec 2012

    Posted 01 May 2014 Link to this post

    Ok I have solved the problem. The binding DataType to the column is DateTime, which don't accept null values. Null values is what the GridView produces upon clicking add new row. When such thing happens, DateTime will auto return 01/01/0001, which is then passed to the RadDatePicker. The solution is to change the datatype to Nullable DateTime, which is 'DataType?'.

    This would mean all related codes have to be modified accordingly at back-end to suit the new datatype.
  3. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 01 May 2014 Link to this post


    Thank you for sharing your solution with the community. 

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top