This is a migrated thread and some comments may be shown as answers.
change raddatetimepicker values in code behind
1 Answer 41 Views
This is a migrated thread and some comments may be shown as answers.
sf
Top achievements
Rank 1
sf asked on 20 Apr 2011, 03:00 AM
on a button click "btn1_Click" event on server side, i want to change the time value in the raddatetimepicker to a new time value.
Is this possible?

thanks in advance

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 20 Apr 2011, 05:56 AM
Hello Sf,

Try the following approach to achieve your requirement.
aspx:
<telerik:RadDateTimePicker ID="DateTimePicker1" SelectedDate="12/12/2011" runat="server">
</telerik:RadDateTimePicker>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
C#:
protected void Button1_Click(object sender, EventArgs e)
  {
      DateTime selectedTime=new DateTime();
      selectedTime=Convert.ToDateTime(DateTimePicker1.SelectedDate);
      DateTime time = new DateTime((int)selectedTime.Year, (int)selectedTime.Month, (int)selectedTime.Day, 12, 12, 12);
      DateTimePicker1.SelectedDate = time;
  }

Thanks,
Shinu.
Asked by
sf
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or