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

RadCalendar Removing dates does not removes alternate dates for day of week

1 Answer 47 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
CJ
Top achievements
Rank 1
CJ asked on 16 Dec 2011, 11:34 AM

Hello,
When i click on column header of the radcalendar it selects all the days of week for that month, ie. When i click on 'W' then it selects all the Wednesdays for that month. But what i want is when i click on 'W' then it should select all the Wednesdays for an entire date range (range i have set using rangemindate and rangemaxdate span across 10 months) after asking a confirmation

For this i have done the following

string day = "Wednesday"; // i am setting this value dynamically through client side OnColumnHeaderClick
for (DateTime date = rangeStart; date.CompareTo(rangeEnd) < 1; date = date.AddDays(1))
                {
                    if (day == Enum.GetName(typeof(DayOfWeek), date.DayOfWeek)) 
                    {
                        RadDate rd = new RadDate(date);
                        radCalendarAM.SelectedDates.Add(rd);
                    }
                }

This works perfectly when selecting dates. Now if i click on the same column header again i want to remove all the "wednesdays" for the entire date range. To remove i have done the following

DayOfWeek dow = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), day);
                for (int i = 0; i < radCalendarAM.SelectedDates.Count; i++)
                {
                    RadDate date = (RadDate)radCalendarAM.SelectedDates[i];
                    if (date.Date.DayOfWeek == dow)
                    {
                        radCalendarAM.SelectedDates.RemoveAt(i);
                    }
                }

But this code does'nt remove all the Wednesdays in the date range, it leave behind alternate wednesdays (or which ever day) selected.
Can you advice on this?

-thanks



1 Answer, 1 is accepted

Sort by
0
CJ
Top achievements
Rank 1
answered on 16 Dec 2011, 06:10 PM
Tags
Calendar
Asked by
CJ
Top achievements
Rank 1
Answers by
CJ
Top achievements
Rank 1
Share this question
or