ForEach DataItem

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

    Posted 09 Oct Link to this post

    hi

    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
    Admin
    Nencho avatar
    1457 posts

    Posted 12 Oct Link to this post

    Hello,

    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:

    http://docs.telerik.com/devtools/aspnet-ajax/controls/scheduler/server-side-programming/server-events/appointmentdatabound


    Regards,
    Nencho
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top