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

[Solved] Grid value in red color

4 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
PM
Top achievements
Rank 1
PM asked on 30 Nov 2009, 10:52 AM
Hi All,

I have a RadGrid with a column "Status".

How can i make the value of Status column in RED color when value is "Open".

Please help me regarding this.

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 30 Nov 2009, 11:03 AM
Hello Praveen,

Please go through the following help topic:
Conditional Formatting for rows/cells on ItemDataBound

Let us know if you need further assistance.

Kind regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
PM
Top achievements
Rank 1
answered on 30 Nov 2009, 11:38 AM
Sorry, i tried it but not working.

My Status column is "GridTemplateColumn".
0
Princy
Top achievements
Rank 2
answered on 30 Nov 2009, 12:14 PM
Hello Praveen,

You would have to access the control in the ItemTemplate of the TemplateColumn and then format it according to your requirement:
aspx:
<telerik:GridTemplateColumn> 
  <ItemTemplate> 
        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Status") %>'></asp:Label>                                
  </ItemTemplate> 
</telerik:GridTemplateColumn> 

c#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem dataItem = (GridDataItem)e.Item; 
            Label lbl = (Label)dataItem.FindControl("Label1"); 
            if (lbl.Text == "Open")             
                lbl.ForeColor = System.Drawing.Color.Red;             
        } 
    } 

Thanks
Princy.
0
PM
Top achievements
Rank 1
answered on 30 Nov 2009, 12:23 PM
Thank You.
Tags
Grid
Asked by
PM
Top achievements
Rank 1
Answers by
Daniel
Telerik team
PM
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or