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

Special Days from Database

4 Answers 193 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
D O
Top achievements
Rank 1
D O asked on 20 Jul 2009, 02:05 PM
Hi there

I'm reading about 40 dates from a database table and I would like to automatically select these dates in a radcalendar.  I want the user to the de-select any days that were automatically selected, or add new days by selected them.

Here's a simple demonstration of what my code looks like using a simple loop to select days 23, 24 and 25.

 

Dim i As Integer

 

 

For i = 23 To 25

 

 

Dim NewDay As New Telerik.Web.UI.RadCalendarDay(RadCalendar1)

 

NewDay.Date =

New DateTime(2009, 7, i)

 

RadCalendar1.RangeMinDate = DateTime.Now

RadCalendar1.SpecialDays.Add(NewDay)

RadCalendar1.SpecialDays(NewDay).IsSelectable =

True

 

RadCalendar1.SpecialDays(NewDay).IsSelected =

True 

 

RadCalendar1.SpecialDays(NewDay).ItemStyle.BackColor = Drawing.Color.Red

 

 

Next

When I do this, the calendar actually highlights the special days in red.  But for some reason the IsSelected=True property is ignored.  I do however think that the days are selected because when I run the mouse over them they change color to the mouse-over color.  However, when I submit the calendar, NO DATES are coming up in my list of selected dates.  I have to physically click each day myself and then submit before they come up.

How would I automatically select several dates and highlight them in the radcalendar and then allow the user to de-select or select more dates.  I then want to a)  clear all previously stored special days in the database and b) post all selected dates to the database table.

Thanks
D.

 

4 Answers, 1 is accepted

Sort by
0
ManniAT
Top achievements
Rank 2
answered on 20 Jul 2009, 02:31 PM
Hi D O,

I never tried "IsSelected" - but
RadCalendar1.SelectedDates.Add(new RadDate(NewDay.Date)); 
as a replacement for the "IsSelected" should help.

Regards

Manfred
0
D O
Top achievements
Rank 1
answered on 20 Jul 2009, 02:47 PM
Hi Manfred

I'm using VB.NET.
In the end this worked for me:

 

Dim RadDate As New Telerik.Web.UI.RadDate()

 

RadDate.Date =

"2009-07-21"

 

 

RadCalendar1.SelectedDates.Add(RadDate)

Now I'm just going to loop through the records and add them one by one.
Thanks for your help.

0
ManniAT
Top achievements
Rank 2
answered on 20 Jul 2009, 03:09 PM
Sorry I didn't take care about your code language

So in VB it shoul look like this (no need for an extra variable)

Dim i As Integer   
'moved here . no need to set it in every loop :)  
RadCalendar1.RangeMinDate = DateTime.Now  
   
 
For i = 23 To 25   
 
Dim NewDay As New Telerik.Web.UI.RadCalendarDay(RadCalendar1)   
 
NewNewDay.Date = New DateTime(2009, 7, i)   
 
RadCalendar1.SpecialDays.Add(NewDay)  
RadCalendar1.SpecialDays(NewDay).ItemStyle.BackColor = Drawing.Color.Red  
 
'here is the line  
RadCalendar1.SelectedDates.Add(new Telerik.Web.UI.RadDate(NewDay))  
 
 
Next  
 
 

Regards

Manfred
PS: if the post solved your problem - please "mark it answer"
0
ManniAT
Top achievements
Rank 2
answered on 20 Jul 2009, 03:10 PM
Forum problems resulted in a double post...
Tags
Calendar
Asked by
D O
Top achievements
Rank 1
Answers by
ManniAT
Top achievements
Rank 2
D O
Top achievements
Rank 1
Share this question
or