Rad:Grid Change Row BackGround Color (RadGrid)

Change the back color of the expanded row and the collapsed rows.

protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {

        //Expand a row , update the backcolor of the expanded row and other rows.
        if (e.CommandName == RadGrid.ExpandCollapseCommandName && e.Item.Expanded == false)
        {
            

          foreach (GridDataItem item2 in RadGrid1.MasterTableView.Items)
            {
                if (item2 == (GridDataItem)e.Item)
                {
                    item2.BackColor = System.Drawing.Color.White;
                }
                else
                {
                    item2.BackColor = System.Drawing.Color.Gainsboro;
                }
            }
        }

        

        //Collaps a row , update the backcolor of all rows.

        if (e.CommandName == RadGrid.ExpandCollapseCommandName && e.Item.Expanded == true)
        {
            foreach (GridDataItem item2 in RadGrid1.MasterTableView.Items)
            {
                item2.BackColor = System.Drawing.Color.White;               
            }
        }  

    }

http://www.telerik.com/community/forums/aspnet-ajax/grid/rad-grid-change-row-background-color.aspx

http://www.telerik.com/community/forums/aspnet/grid/set-background-color-of-a-row-in-client-script.aspx

http://www.telerik.com/community/forums/aspnet-ajax/grid/grid-row-background-colour-confliction.aspx

http://www.telerik.com/help/aspnet-ajax/grdaccessingcellsandrows.html

原文地址:https://www.cnblogs.com/emanlee/p/1524752.html