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

Change conditionnaly font color in GridNumericColumn

1 Answer 118 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cedric
Top achievements
Rank 2
Cedric asked on 23 Jul 2008, 06:10 PM
I use a GridNumericColumn to display an amount of money.  If the amount of money is negative, i want to change the font color to red.  Is there is any property allowing me to do so?

thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 24 Jul 2008, 06:13 AM
Hi Cedric,

Try the following code snippet to achieve the desired scenario.

ASPX:
<telerik:GridNumericColumn DataField="Num" NumericType="Number" UniqueName="Num" ></telerik:GridNumericColumn> 
                         

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string strtxt = item["Num"].Text.ToString(); 
            if (strtxt.Contains("-")) 
            { 
                item["Num"].ForeColor = System.Drawing.Color.Red; 
            } 
        } 
     } 


Thanks
Shinu.
Tags
Grid
Asked by
Cedric
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or