using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("TaskID");
        table.Columns.Add("Task");
        table.Columns.Add("Process");

        Random random = new Random();
        for (int i = 0; i < 10; i++)
        {
            DataRow row = table.NewRow();
            row["TaskID"] = 1000 + i;
            row["Task"] = "Task" + i.ToString();
            row["Process"] = random.Next(0, 100);

            table.Rows.Add(row);
        }
        RadGrid1.DataSource = table;
    }
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            int process = int.Parse((item.DataItem as DataRowView)["Process"].ToString());
            HtmlControl div = item["Process"].FindControl("divProcess") as HtmlControl;
            div.Style["width"] = process.ToString() + "%";
            if (process < 30)
            {
                div.Style["background-color"] = "red";
            }
            if (process > 30 && process <= 60)
            {
                div.Style["background-color"] = "yellow";
            }
            if (process > 60)
            {
                div.Style["background-color"] = "green";
            }
        }
    }
}
