Rock.Web.UI.Controls.ColorField.cell_DataBinding C# (CSharp) Method

cell_DataBinding() protected method

Handles the DataBinding event of the cell control.
protected cell_DataBinding ( object sender, EventArgs e ) : void
sender object The source of the event.
e System.EventArgs The instance containing the event data.
return void
        protected void cell_DataBinding( object sender, EventArgs e )
        {
            if ( sender is TableCell )
            {
                TableCell cell = sender as TableCell;
                GridViewRow row = ( sender as TableCell ).Parent as GridViewRow;

                if ( row.DataItem != null )
                {
                    string dataValue = row.DataItem.GetPropertyValue( this.DataField ) as string;
                    string toolTipValue = string.Empty;
                    if ( !string.IsNullOrWhiteSpace( this.ToolTipDataField ) )
                    {
                        toolTipValue = row.DataItem.GetPropertyValue( this.ToolTipDataField ) as string;
                    }

                    cell.ToolTip = toolTipValue;
                    cell.Style[HtmlTextWriterStyle.BackgroundColor] = dataValue;
                }
            }
        }