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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Conditional Format of Row

Thread ID:





73602 May 12,2008 08:03 PM UTC May 20,2008 04:04 AM UTC ASP.NET Web Forms (Classic) 3
Tags: GridGroupingControl
David A. Gonzales
Asked On May 12, 2008 08:03 PM UTC

I was wondering if it's possible to use the GridConditionalFormatDescriptor expression but instead of formatting the whole row just certain columns? I would like to do something like "if the percentage value [Percent_Value] is greater than 90% then set the Result [Result] column to the color Red":

gcfd1.Expression = "[Percent_Value] > 90";

then only format column [Result] to red.

I can use the GridGroupingControl1_QueryCellStyleInfo event and handle the colIndex and rowIndex but it's not very general in nature.

Maybe something like:

Color c1 = Color.FromName("Red");
gcfd1.Appearance.Column["Result"].TextColor = c1;
gcfd1.Appearance.Column["Result"].Font.Bold = true;

if that is possible?


Janagan [Syncfusion]
Replied On May 16, 2008 10:47 AM UTC

Hi David,

Thanks for posting your query to us.

I regret to let you know that the formatting of specific cells based on conditions can be achieved only through QueryCellStyleInfo event. But you can apply format based on conditions for the entire row. Please refer the following code snippet:

protected void Page_Load(object sender, EventArgs e)
GridConditionalFormatDescriptor gcfd1 = new GridConditionalFormatDescriptor();

gcfd1.Expression= "[CategoryID]<2";

gcfd1.Appearance.AnyRecordFieldCell.BackColor = System.Drawing.Color.Red;


To apply format for specific column:

protected void GridGroupingControl1_QueryCellStyleInfo1(object sender, GridTableCellStyleInfoEventArgs e)

if ((e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell))

if (e.TableCellIdentity.Column.Name == "CategoryID")

val1 = (System.Int32)e.Style.CellValue;

if (e.TableCellIdentity.Column.Name == "SupplierID")
val2 = (System.Int32)e.Style.CellValue;
if ((val2 < val1)&&(e.TableCellIdentity.Column.Name == "CategoryID"))

e.Style.TextColor = System.Drawing.Color.Magenta;



Please refer the sample in the link below which illustrates the above:


Please try running the sample and let me know if this helps.


David A. Gonzales
Replied On May 16, 2008 04:59 PM UTC

Thanks. I am using the QueryCellStyleInfo to handle this situation. We are just defining the cells that need to be updated elsewhere and then while the QueryCellStyleInfo is called we determine whether the cell needs to be formated or not. Just an extra step but not too bad.


Janagan [Syncfusion]
Replied On May 20, 2008 04:04 AM UTC

Hi David,

Thanks for the update. Please let me know if you have any other questions.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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