We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Condtional Formatting for the GridGroupingControl

Thread ID:

Created:

Updated:

Platform:

Replies:

101342 Oct 17,2011 04:53 PM UTC Oct 28,2011 05:49 AM UTC ASP.NET Web Forms (Classic) 1
loading
Tags: GridGroupingControl
Felix
Asked On October 17, 2011 04:53 PM UTC

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



Sridhar N [Syncfusion]
Replied On 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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;