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

How to change the Row color In rad grid

1 Answer 529 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ashok
Top achievements
Rank 1
Ashok asked on 31 Jan 2011, 07:11 AM
Hi

I'm Using this default for my grid. i want to change the row color for some condition in rad item databound. but it changing the row color.
when i mouse over the row of the changed color i'm getting default color that from (item Created) on mouse out i'm getting white color (item created) but i need that Changed color from item databound.

protected void Grd1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            GridItemType item = e.Item.ItemType;

            switch (item)
            {
                case GridItemType.AlternatingItem:
                case GridItemType.Item:

                    TableRow row = e.Item as TableRow;
                    string clr = "white";

                    row.Attributes.Add("onmouseover", "this.style.backgroundColor = 'Yellow';");
                    row.Attributes.Add("onmouseout", "this.style.backgroundColor = '" + clr + "';");
                    break;
            }
        }

protected void Grd1_ItemDataBound(object sender, GridItemEventArgs e)
        {

if ((e.Item.ItemType == GridItemType.Item) || (e.Item.ItemType == GridItemType.AlternatingItem))
            {

string _No= grdScheduledPatients.MasterTableView.DataKeyValues[e.Item.ItemIndex]["Datakey"].ToString();

if (_No == "1")
                {
                    e.Item.BackColor = System.Drawing.Color.Green;
                }

}
        }

Give me idea How to change the row color without change the old row color..


Regards,
Ashok Anbarasu

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 02 Feb 2011, 03:13 PM
Hello Ashok,

I recommend that you examine the following link:
Conditional Formatting for rows/cells on ItemDataBound

Best wishes,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Ashok
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or