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

2 posts, 0 answers
  1. CJ
    CJ avatar
    6 posts
    Member since:
    Dec 2010

    Posted 16 Dec 2011 Link to this post

    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



  2. CJ
    CJ avatar
    6 posts
    Member since:
    Dec 2010
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top