views:

168

answers:

1

Has anyone used plexityhide's GTP.NET for asp.net 3.5 as im trying to colour the individual cells based on a var that im getting from a linq query as follows

PilotDataContext pilot = new PilotDataContext();

var schedule = from x in pilot.slot_tbl_Schedules select x;

foreach (var s in schedule)
{
    if (s.AppointmentType == "Repair")
    {
        CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
        gn.GetCell(0).Layout = cll;
        cl.BackgroundColor = Color.Red;
        cl.SelectedColor = Color.Red; 
    }
    else if (s.AppointmentType == "Service")
    {
        CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
        gn.GetCell(0).Layout = cl;
        cl.BackgroundColor = Color.Blue;
    }
    else if (s.AppointmentType == "TravelTime")
    {
        CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
        gn.GetCell(0).Layout = cl;
        cl.BackgroundColor = Color.Green;
    }
    else if (s.AppointmentType == "AnnualLeave")
    {
        CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
        gn.GetCell(0).Layout = cl;
        cl.BackgroundColor = Color.Yellow;
    }
}

the syntax in the if statement is what they have recommended can anyone help on this

Many Thanks

+1  A: 

Make sure you set the CellLayout.BackgroundUse=true. If you don't the Background color is ignored.

And since you use ASP.NET the cellLayouts will generate a css, so you must add the new cloned CellLayouts to the collection on CellLayouts:

Gantt_ASP.Gantt.Grid.CellLayouts.Add(cl);