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

Color parts of string in RadGrid Column

1 Answer 83 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jan
Top achievements
Rank 1
Jan asked on 07 Jan 2011, 03:52 PM
Hi guys,

I have following question:

I want to color only a part of a string in a cell like the "firefox search".
I use a GridBoundColumn. Is this possible?

See the screenshot to understand what a mean :)

Jan

1 Answer, 1 is accepted

Sort by
0
Mike Nogen
Top achievements
Rank 1
answered on 07 Jan 2011, 04:10 PM
Hello!

I´m sure there are better ways to solve this. But a simple soultion that works is like this.

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
       {
           //when the Grid is in normal mode   
           if (e.Item is GridDataItem)
           {
               GridDataItem item = e.Item as GridDataItem;
               string textYourSearchFor = "test";
               item["AddedBy"].Text = item["AddedBy"].Text.Replace(textYourSearchFor, "<font color=red><b>" + textYourSearchFor + "</b></font>");
           }
       }
Tags
Grid
Asked by
Jan
Top achievements
Rank 1
Answers by
Mike Nogen
Top achievements
Rank 1
Share this question
or