Set dateTimeBirthDate.DateInput.Text in CodeBehind

5 posts, 0 answers
  1. Ricky
    Ricky avatar
    247 posts
    Member since:
    Jun 2007

    Posted 27 Aug 2008 Link to this post

    Hi,

    I need to set DateTimePicker.DateInput.Text in codebehind, but the following error occurs when I set as dateTimeBirthDate.DateInput.Text = "2007/11/12"; for example.

    Text property cannot be set. String was not recognized as a valid DateTime.

    How could I set this property appropriately?

    Thanks,
    Ricky.
  2. Pavel
    Admin
    Pavel avatar
    904 posts

    Posted 28 Aug 2008 Link to this post

    Hi Ricky,

    When working with a RadDatePicker you should use its SelectedDate property to change the value in the DateInput. Since this property is of type System.DateTime you should parse the string that you want to pass to the picker like this:
    RadDateTimePicker1.SelectedDate = System.DateTime.Parse("2007/11/12"); 

    I hope this helps.

    Sincerely yours,
    Pavel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ricky
    Ricky avatar
    247 posts
    Member since:
    Jun 2007

    Posted 28 Aug 2008 Link to this post

    Hi Pavel

    I know the way you provide to me. But we are leveaging wwDataBinder http://msdn.microsoft.com/en-us/magazine/cc163505.aspx to help data-binding process, and wwDataBinder is best to bind the value to controls' Text property.
    Hence, if DateTimePicker.DateInput.Text can be assigned DateTime-format string, it would save us a lot.

    Thanks,
    Ricky.
  5. Plamen Peshev
    Admin
    Plamen Peshev avatar
    886 posts

    Posted 29 Aug 2008 Link to this post

    Hello Ricky,


    Binding a RadDatePicker, RadTimePicker, or RadDateTimePicker control to a data source is easy provided you use the DbSelectedDate property. It works almost like the SelectedDate one, but does not throw an exception when given a null value.

    In addition you can review the following help article:
    http://www.telerik.com/help/aspnet-ajax/calendar_pickerdatabinding.html

    Sincerely yours,
    Plamen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Prashanth
    Prashanth avatar
    6 posts
    Member since:
    Jan 2013

    Posted 29 Jan 2013 Link to this post

    Hi,

       I have a set of dates in database randomly . I am using raddatepicker  . My issue was how to provide the dates to raddatepicker from database and only those dates should be enable , Remaining all dates should be disabled and cannot be selected.What is way to disable all dates expect those are in my database.

    Regards,
    Prashanth.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017