6 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 08 Nov 2012, 04:30 AM
Hi Dario,
I suppose you want to change the timeview (starttime, endtime and interval) in SelectedDateChanged Event. Here is the sample code that I tried.
C#:
Hope this helps.
Thanks,
Princy.
I suppose you want to change the timeview (starttime, endtime and interval) in SelectedDateChanged Event. Here is the sample code that I tried.
C#:
protected
void
RadDateTimePicker1_SelectedDateChanged(
object
sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
{
TimeSpan start =
new
TimeSpan(2, 0, 0);
TimeSpan end =
new
TimeSpan(10, 0, 0);
TimeSpan interval =
new
TimeSpan(2, 0, 0);
RadDateTimePicker11.TimeView.StartTime = start;
RadDateTimePicker11.TimeView.EndTime = end;
RadDateTimePicker11.TimeView.Interval = interval;
}
Hope this helps.
Thanks,
Princy.
0

Dario
Top achievements
Rank 2
answered on 08 Nov 2012, 08:07 AM
I explain my situation:
I have a RadCalendar controllo and RadDropBox.
I have to select an item of RadDropBox, this item gives me some information (starttime, endtime and interval).
After this I select a date on RadCalendar, this controlo has AutoPostBack = true.
Into RadCalendar_SelectDateChanged (I don't remember if this is the name of this event), I must change properties of a RadDateTimePicker.
I done this, but gives me a trange effect: I must click 2 times on RadCalendar because on first time I don't obtain a correctly configuration of RadDateTimePicker.
I don't undestand why this...
I have a RadCalendar controllo and RadDropBox.
I have to select an item of RadDropBox, this item gives me some information (starttime, endtime and interval).
After this I select a date on RadCalendar, this controlo has AutoPostBack = true.
Into RadCalendar_SelectDateChanged (I don't remember if this is the name of this event), I must change properties of a RadDateTimePicker.
I done this, but gives me a trange effect: I must click 2 times on RadCalendar because on first time I don't obtain a correctly configuration of RadDateTimePicker.
I don't undestand why this...
0

Princy
Top achievements
Rank 2
answered on 09 Nov 2012, 04:23 AM
Hi Dario,
Unfortunately I couldn't replicate the issue you are facing. Here is the full code that I tried based own your scenario which works as expected.
ASPX:
Please provide your code if this doesn't helps.
Thanks,
Princy.
Unfortunately I couldn't replicate the issue you are facing. Here is the full code that I tried based own your scenario which works as expected.
ASPX:
<
telerik:RadComboBox
ID
=
"RadComboBox1"
runat
=
"server"
>
<
Items
>
<
telerik:RadComboBoxItem
Text
=
"one"
Value
=
"1"
/>
<
telerik:RadComboBoxItem
Text
=
"two"
Value
=
"2"
/>
<
telerik:RadComboBoxItem
Text
=
"three"
Value
=
"3"
/>
</
Items
>
</
telerik:RadComboBox
>
<
telerik:RadCalendar
ID
=
"RadCalendar1"
runat
=
"server"
AutoPostBack
=
"true"
onselectionchanged
=
"RadCalendar1_SelectionChanged"
>
</
telerik:RadCalendar
>
<
telerik:RadDateTimePicker
ID
=
"RadDateTimePicker1"
runat
=
"server"
>
</
telerik:RadDateTimePicker
>
Please provide your code if this doesn't helps.
Thanks,
Princy.
0

Dario
Top achievements
Rank 2
answered on 09 Nov 2012, 07:33 AM
Ok thank you for support:
RadCalendar_SelectionChanged(
object
sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
{
//Set monday day relative to user selected date
DateTime selezionato = e.SelectedDates.Count == 1 ? e.SelectedDates[0].Date : DateTime.Today;
DayOfWeek giornoSettimanaleDiOggi = selezionato.DayOfWeek;
DateTime lunedì =
new
DateTime();
if
(giornoSettimanaleDiOggi == DayOfWeek.Sunday)
lunedì = selezionato.AddDays(-6);
else
lunedì = selezionato.AddDays((Convert.ToInt32(giornoSettimanaleDiOggi) - 1) * -1);
RicercaRadCalendar.SelectedDate = lunedì;
//After Change TimeView of RadDateTimePicker
CustomTimeView MyItemSelected = ConvertValueToMyItemSelected(FieldDropDownList.SelectedValue);
RadDateTimePicker.TimeView.StartTime = MyItemSelected.StartTime;
RadDateTimePicker.TimeView.EndTime = MyItemSelected.EndTime;
RadDateTimePicker.TimeView.Interval = MyItemSelected.Interval;
}
public
class
CustomTimeView
{
TimeSpan StartTime {
get
;
set
;}
TimeSpan EndTime {
get
;
set
;}
TimeSpan Interval {
get
;
set
;}
[..]
}
0

Princy
Top achievements
Rank 2
answered on 12 Nov 2012, 09:50 AM
Hi Dario,
Try the following code to achieve your scenario.
C#:
Thanks,
Princy.
Try the following code to achieve your scenario.
C#:
public
CustomTimeView ConvertValueToMyItemSelected(
string
value)
{
CustomTimeView data =
new
CustomTimeView();
data.StartTime =
new
TimeSpan(2, 0, 0);
data.EndTime =
new
TimeSpan(10, 0, 0);
data.Interval =
new
TimeSpan(Convert.ToInt32(value), 0, 0);
return
data;
}
protected
void
RadCalendar_SelectionChanged(
object
sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
{
//Set monday day relative to user selected date
DateTime selezionato = e.SelectedDates.Count == 1 ? e.SelectedDates[0].Date : DateTime.Today;
DayOfWeek giornoSettimanaleDiOggi = selezionato.DayOfWeek;
DateTime lunedì =
new
DateTime();
if
(giornoSettimanaleDiOggi == DayOfWeek.Sunday)
lunedì = selezionato.AddDays(-6);
else
lunedì = selezionato.AddDays((Convert.ToInt32(giornoSettimanaleDiOggi) - 1) * -1);
RicercaRadCalendar.SelectedDate = lunedì;
//After Change TimeView of RadDateTimePicker
CustomTimeView MyItemSelected = ConvertValueToMyItemSelected(FieldDropDownList.SelectedValue);
RadDateTimePicker1.TimeView.StartTime = MyItemSelected.StartTime;
RadDateTimePicker1.TimeView.EndTime = MyItemSelected.EndTime;
RadDateTimePicker1.TimeView.Interval = MyItemSelected.Interval;
}
Thanks,
Princy.
0

Dario
Top achievements
Rank 2
answered on 13 Nov 2012, 09:25 AM
Thank you very much!
I understud that my problem was the "selecting date" and forcing date to relative monday day.
Infact, during this second select I'm creating strange environment.
Then, I set this code only when e.SelectedDates[0] is Monday
By this way it's ok!
I understud that my problem was the "selecting date" and forcing date to relative monday day.
Infact, during this second select I'm creating strange environment.
Then, I set this code only when e.SelectedDates[0] is Monday
//After Change TimeView of RadDateTimePicker
CustomTimeView MyItemSelected = ConvertValueToMyItemSelected(FieldDropDownList.SelectedValue);
RadDateTimePicker1.TimeView.StartTime = MyItemSelected.StartTime;
RadDateTimePicker1.TimeView.EndTime = MyItemSelected.EndTime;
RadDateTimePicker1.TimeView.Interval = MyItemSelected.Interval;
By this way it's ok!