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

[Solved] Checking RadGrid Values

2 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kenneth
Top achievements
Rank 1
Kenneth asked on 23 Oct 2009, 04:33 AM
hello there

I have the following radgrid  and a button

=========================================================
ID     Number
--      ---------
1        100.00
2         999.00
3         666.000

--Click Me--
=========================================================





I am trying to do when the user clicks on --Click Me--

--> it actually loops thru all the radgrid and  check the column (Numbers)
--> if the number is > 500.00 then the font is red else blue

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Oct 2009, 05:46 AM
Hi Kenneth,

Try the following code snippet in order to change the color of text according to value.

CS:
 
protected void Button1_Click(object sender, EventArgs e) 
    foreach( GridDataItem item in RadGrid1.MasterTableView.Items ) 
    { 
        int num =  Convert.ToInt32(item["Number"].Text); 
        if (num > 500) 
        { 
            item["Number"].ForeColor = System.Drawing.Color.Red;                
        } 
        else 
        { 
            item["Number"].ForeColor = System.Drawing.Color.Blue; 
        } 
    } 

-Shinu.
0
Kenneth
Top achievements
Rank 1
answered on 23 Oct 2009, 06:28 AM
thanks it works

Tags
Grid
Asked by
Kenneth
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Kenneth
Top achievements
Rank 1
Share this question
or