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

How to dynamically change fore color of hyperlinkcolumn data??

2 Answers 29 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Effat
Top achievements
Rank 1
Effat asked on 07 Sep 2011, 09:33 AM
Hello,

I'm trying to change the fore color of hyperlink column data on a condition but since I have applied Windows7 skin on the grid, it overrides my colors.. I really need to keep windows7 skin on the grid but I have to change the color conditionally.. Please help!

Regards,
Effat

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 07 Sep 2011, 09:41 AM
Hello,

<telerik:GridHyperLinkColumn DataTextField="ID" NavigateUrl="#" UniqueName="IdHyperLink"></telerik:GridHyperLinkColumn>
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
 
            string StrID = (item["IdHyperLink"].Controls[0] as HyperLink).Text;
            if (StrID == "Your Compared String")
            {
                (item["IdHyperLink"].Controls[0] as HyperLink).ForeColor = Color.Red;
            }
        }
    }

Let me know if any concern.

Thanks,
Jayesh Goyani

0
Effat
Top achievements
Rank 1
answered on 07 Sep 2011, 09:53 AM
Thank you Jayesh Goyani, It worked perfectly :)
Tags
Grid
Asked by
Effat
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Effat
Top achievements
Rank 1
Share this question
or