This is a migrated thread and some comments may be shown as answers.

ForEach DataItem

1 Answer 29 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 10 Oct 2016, 04:23 AM

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;
        }
              


    }

1 Answer, 1 is accepted

Sort by
0
Accepted
Nencho
Telerik team
answered on 12 Oct 2016, 10:19 AM
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.
Tags
Scheduler
Asked by
L
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or