Q:

How to format radgrid cell programmatically

I have to format (backcolor, forecolor, font style) a radgrid's cells depending on the value of the cell.
For example 
If the value is negative set the fore color of that cell as red.
Can any one please tell me how this can be achieved?

A:

 protected void grdName_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            if (Convert.ToInt32(((DataRowView)item.DataItem)["Column"]) < value)
            {
                TableCell cell = item["Column"];
                cell.BackColor = Color.PeachPuff;
            }
        }
    }

A:

Add the line onItemDataBound="Data_OnitemDataBound" to your radGrid declaration in your aspx page.
Then add this to your code behind.  The number in the Cells[] is the index of the column you want to modify or validate against.
protected void Data_OnItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        if (Convert.ToDecimal(item.Cells[3].Text) < 0)
        {
            item.Cells[3].ForeColor = System.Drawing.Color.Red;
        }
    }
}

