Condtional Formatting for the GridGroupingControl

Hello,

I am trying to set up the colors of the whole row based off a value of a column which is extracted from a data source. I did it in ASP.net gridview using this code, now just trying to transfer it to GridGroupingControl.


If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.Cells(3).Text = "-1" Then
e.Row.BackColor = System.Drawing.Color.Red
End If
If e.Row.Cells(3).Text = "0" Then
e.Row.BackColor = System.Drawing.Color.Yellow
End If
If e.Row.Cells(3).Text = "1" Then
e.Row.BackColor = System.Drawing.Color.Green
End If
If e.Row.Cells(3).Text <> "0" Or "1" Or "-1" Then
e.Row.BackColor = System.Drawing.Color.Yellow
End If
End Sub



1 Reply

SN Sridhar N Syncfusion Team October 28, 2011 05:49 AM UTC

Hi Fleix,

Thanks for your patience.

Your requirement can be achieved by handling the RowDataBound event. Please refer the below code snippet.

[Codebehind - C#]

void GridGroupingControl1_RowDataBound(object sender, RowDataBoundEventArgs e)
{
if (e.Row != null)
{
if (e.Row.DisplayElement.Kind == DisplayElementKind.Record)
{
if (Convert.ToInt32(e.Row.Cells[3].Text)% 2 == 0)
{
e.Row.BackColor = Color.Red;
}
}
}
}



For your convenience, we have created sample and the same can be downloaded from the following link.

RowDataBound color-1755674350.zip

Please let me know if you have any other questions or concerns.

Regards,
Sridhar.N


Loader.
Up arrow icon