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

Colours changing but not correct

1 Answer 24 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 10 Aug 2012, 11:50 PM
I have a radscheduler on a webform and have this code.  It is probably something really stupid that I can't see so here goes.

I have a table of users and schedules.  The users have a named colour stored in the table.

What I am try to achieve?

I am tried to get all the schedules for the users and make their appointments show up in the specified colour stored in the database.

I have a small issue of retaining the correct colour as all the other colours are overwritten by the last loop.

Example.

User1 -----  Red
User2 -----  Blue

When the Schedule is rendered all the items are blue.  Is there a way around this?  Or am I making a schoolboy error?  I hnave already tried the same code on AppointmentOnDataBound

protected void EngSchedule_AppointmentCreated(object sender, Telerik.Web.UI.AppointmentCreatedEventArgs e)
       {
           DataTable table = PageAccess.GetEngSchedule();
           
           foreach (DataRow dataRow in table.Rows)
           {
               var c = dataRow["Colour"].ToString();  //first colour Red, second colour Blue
               e.Appointment.BackColor = Color.FromName(c); // Appointments always blue WHY??
           }
       }

Can someone please tell me why the second colour overwrites the first colour

1 Answer, 1 is accepted

Sort by
0
Simon
Top achievements
Rank 1
answered on 12 Aug 2012, 10:08 AM
I have solved the issue myself.

Here is my code.
protected void EngSchedule_AppointmentDataBound(object sender, SchedulerEventArgs e)
       {
           DataTable table = PageAccess.GetEngSchedule();
           int i = 0;
 
           foreach(Appointment appointment in EngSchedule.Appointments)
           {
               DataRow dr = table.Rows[i];
               appointment.BackColor = Color.FromName(dr["Colour"].ToString());
               i++;
           }
 
 
       }
Tags
Scheduler
Asked by
Simon
Top achievements
Rank 1
Answers by
Simon
Top achievements
Rank 1
Share this question
or