RadCalendar with EnableMultiSelect loses specialdays data upon navigation

2 posts, 0 answers
  1. Sivakumar Chandran
    Sivakumar Chandran avatar
    1 posts
    Member since:
    Dec 2009

    Posted 23 Dec 2009 Link to this post

    This is the definition we have in .aspx

     

     

    <telerik:RadCalendar ID="RadCalendar2" runat="server" Font-Names="Arial,Verdana,Tahoma"

     

     

     

    ForeColor="Black" Skin="Outlook" Style="border-color: #ececec"

     

     

     

    EnableViewSelector="True" AutoPostBack="false">

     

     

     

    </telerik:RadCalendar>

     

     

     

    A function with the following lines is called on pageload:

     

    RadCalendar2.SpecialDays.Clear();

    RadCalendar2.SelectedDates.Clear();

     

     

    RadCalendarDay NewDay = new RadCalendarDay(RadCalendar2);

     

     

     

    foreach (DataRow drrow in dtALLDates.Rows)

     

    {

    NewDay =

    new RadCalendarDay(RadCalendar2);

     

    NewDay.Date =

    Convert.ToDateTime(drrow["CalendarDate"]);

     

    NewDay.ToolTip =

    Convert.ToInt32(drrow["SeatsAvailable"]) > 0 ? Convert.ToInt32(drrow["SeatsAvailable"]) > 1 ? drrow["SeatsAvailable"] + " seats are available" : "1 seat is available"

     

     

     

     

    :

    Convert.ToInt32(drrow["InSchedule"]) == 0 ? "Session not offered or it is a holiday." : "Seats are not available.";

     

     

    Boolean bselect = Convert.ToInt32(drrow["SeatsAvailable"]) > 0 && Convert.ToBoolean(drrow["AllowEdit"]) == true ? true : false;

     

    NewDay.IsSelectable = bselect;

     

    if (Convert.ToBoolean(drrow["IsOpted"]) == true)

     

    {

    NewDay.IsSelected =

    true;

     

    RadCalendar2.SelectedDates.Add(

    new RadDate(Convert.ToDateTime(drrow["CalendarDate"].ToString())));

     

    }

    RadCalendar2.SpecialDays.Add(NewDay);

    }


    When we navigate from one month to another month, the highlighted dates are cleared. I tried lot of things. But nothing working. Please help me to come out of this issue.

    Thanks a lot in advance.

    Siva

  2. Radoslav
    Admin
    Radoslav avatar
    1566 posts

    Posted 29 Dec 2009 Link to this post

    Hi Siva,

    I looked through your code and I think that the problem is caused by the following code line:

    NewDay.IsSelectable = bselect;

    This code made the date in NewDay not selectable, however the next few rows of code select some of the dates:

    if (Convert.ToBoolean(drrow["IsOpted"]) == true)
    {
        NewDay.IsSelected = true;
        RadCalendar2.SelectedDates.Add(new
             RadDate(Convert.ToDateTime(drrow["CalendarDate"].ToString())));
    }

    In some cases this code selects dates which are set to be not selectable.
    Additionally I am attaching a simple example based on your code.
    I hope this helps.

    All the best,
    Radoslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top