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

[Solved] GridDropDown Conditional ForeColor

2 Answers 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Heath Brown
Top achievements
Rank 1
Heath Brown asked on 20 Oct 2009, 09:49 PM
Hello,

I have a GridDropdown column that looks like this:

 

<telerik:GridDropDownColumn DataField="Role_ID" DataType="System.Int32" DataSourceID="SqlDataSource2" ListValueField="Role_ID" ListTextField="RoleName" 
            HeaderText="Role" SortExpression="Role_ID" UniqueName="Role_ID"

The RoleName field from my datasource will display in the column instead of the actual Role_ID.  Is there any way I can turn the non-editmode forecolor of the RoleName to red when the value of Role_ID = 45?

Thanks for any help,
Heath

 

 

2 Answers, 1 is accepted

Sort by
0
Heath Brown
Top achievements
Rank 1
answered on 21 Oct 2009, 10:40 PM
Anyone know this?
0
Mira
Telerik team
answered on 23 Oct 2009, 11:51 AM
Hello Heath,

I suggest that you try handling the ItemDataBound event of the grid in the following way:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && !e.Item.IsInEditMode)
    {
        GridEditableItem editedItem = e.Item as GridEditableItem;
        if (editedItem["Role_ID"].Text == "45")
            editedItem["Role_ID"].Attributes["style"] = "color: red";
                   
    }
}

I hope this helps.

All the best,
Mira
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.
Tags
Grid
Asked by
Heath Brown
Top achievements
Rank 1
Answers by
Heath Brown
Top achievements
Rank 1
Mira
Telerik team
Share this question
or