ForEach DataItem

2 posts, 1 answers
  1. L
    L avatar
    298 posts
    Member since:
    Apr 2008

    Posted 09 Oct 2016 Link to this post


    How do I do a foreach loop in the RadScheduler ItemDataBound event?

    I have a code here would like to have a lightGray background color if the class end time is lesser than current time and i would like to loop through each item so that gray out the correct items. Thanks


     protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
            DataRowView row = (DataRowView)e.Appointment.DataItem;
            DateTime endtime = DateTime.Parse(row["ClassEndTime"].ToString());
            if (endtime <= DateTime.Now)
                e.Appointment.BackColor = System.Drawing.Color.LightGray;


  2. Answer
    Nencho avatar
    1823 posts

    Posted 12 Oct 2016 Link to this post


    The AppointmentDataBound event is triggered for each appointment in the collection for the RadScheduler. Also, it is triggered again for each appointment, when a new one is created.

    With that said, you could simply check e.Appointment when the AppointmentDataBound event is triggered. In addition, you can use the  e.Appointment.End, which will provide you with the end time for the currently evaluated appointment in the handler of the event.

    See AppointmentDataBound documentation article:

    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top