Adding Special Days on demand.

2 posts, 0 answers
  1. Ivan
    Ivan avatar
    9 posts
    Member since:
    Dec 2010

    Posted 31 Jan 2011 Link to this post


    I'm using a DatePicker to show data about a specific date, and there are also dates in which no data is related. Hence, I'm populating the picker with special days using the OnLoad event, enabling and disabling the dates between the MinDate and MaxDate, as it's being needed.

    This is how I've done so far, populating from the picker's MinDate to the MaxDate, which works, but I'd like to populate by requesting dates everytime I navigate, within the picker's CalendarView, so everytime a request occurs, I only process no more than 40 Special Days, not every date of several months and so on:

    protected void DatePicker_Load(object sender, EventArgs e)
                RadDatePicker picker = sender as RadDatePicker;
                DateTime[] dates = controller.GetCustomerBaseDates();
                picker.MinDate = dates.Min();
                picker.MaxDate = dates.Max();
                for (DateTime d1 = picker.MinDate; d1 <= picker.MaxDate; d1 = d1.AddDays(1))
                    RadCalendarDay day;
                    bool exists = dates.Contains(d1);
                    day = new RadCalendarDay { Date = d1, IsSelectable = exists, IsDisabled = !exists };
                    day.ItemStyle.CssClass = exists ? "rcDataExists" : "rcDisabled";

    How could I add the special days every time navigation occurs?  I want to enable and disable these dates on navigation within the view, because a lot of dates would be involved in the process.

  2. Iana Tsolova
    Iana Tsolova avatar
    3388 posts

    Posted 03 Feb 2011 Link to this post

    Hello Ivan,

    In order to achieve your goal, you will need enable the picker's calendar AutoPostBack. However this is not supported out-of-the-box. And to implement it, you can follow the approach illustrated here.

    Check it out and let me know if it works for you.

    All the best,
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top