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

RadDateTimePicker to DateTime value in asp.net

2 Answers 259 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
xeon
Top achievements
Rank 1
xeon asked on 13 Jun 2015, 12:37 PM

Platform :: ASP.NET

Editor ::     VS 2013

I am trying to pass the value of RadDateTimePicker to a function as DateTime value in my code behind file. but it is showing error?

1. How to pass RadDateTimePicker as DateTime value?

2. how to validate the value of RadDateTimePicker is greater then the current system datetime value?

while trying to pass RadDateTimePicker as DateTime value,

//**************************************************

  <telerik:RadDateTimePicker runat="server" ID="regDate" >
           <Calendar ID="Calendar1" runat="server" EnableKeyboardNavigation="true">
           </Calendar>
  </telerik:RadDateTimePicker>

// code behind logic

DateTime getRegDate = regDate;

//**************************************************

shows error ::

can not implicitly convert type 'Telerik.Web.UI.RadDateTimePicker' to 'System.Date.Time' 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 15 Jun 2015, 02:21 PM
Hi Arnab,

In order to access the selected date from a RadDateTimePicker control you should use the SelectedDate property. Note that it returns a nullable type.

The following code snippet illustrates how you can get the selected date and time in the code-behind.

Markup:

<telerik:RadDateTimePicker runat="server" ID="RadDateTimePicer1"></telerik:RadDateTimePicker>
 
<asp:Button ID="Button1" Text="Get selected DateTime" runat="server" OnClick="Button1_Click" />


Code-behind:

protected void Button1_Click(object sender, EventArgs e)
{
    DateTime? selectedDateTime = RadDateTimePicer1.SelectedDate;
 
}


Regards,
Viktor Tachev
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
Hadoop
Top achievements
Rank 1
answered on 17 Jun 2015, 06:52 AM
thanks for the reply!!!
Tags
General Discussions
Asked by
xeon
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Hadoop
Top achievements
Rank 1
Share this question
or