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. Image for the cookie policy date
close icon

GridGroupingControl: How to Change Cell Color on Property value?

I want to change cell color depending on property value.  this property is not a visible/hided coulmn.

its a asp.net web application.

suppose.. I have bound  List<Emp> and

EMP - name , salary , department, gender

Gender is not any column on the GridGroupingControl. It just a property of EMP(either Male/Female).

Now I want change color of "Name" cell who is belongs to Male value

 

    


1 Reply

SK Shanmugaraja K Syncfusion Team October 4, 2013 04:34 AM UTC

Hi Suhas,

 

Thanks for using Syncfusion products.

 

Your requirement of changing the cell color depending on  the property value which did not included in hidden/visible columns in Grid  can be achieved by using RowDataBound Event. Please refer to the below code snippet to achieve this.

 

[CS]

void GridGroupingControl1_RowDataBound(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.RowDataBoundEventArgs e)

 {

 for (int i = 0; i < e.Row.Cells.Count; i++)

            {

            if (((Syncfusion.Web.UI.WebControls.Grid.Grouping.GridCell)(e.Row.Cells[i])).ColumnDescriptor != null)

                {

                   if (((Syncfusion.Web.UI.WebControls.Grid.Grouping.GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "Name")

                    {

                      if ((e.Row.Record!=null) && (e.Row.Record.GetValue("Gender") == "Male"))

                        {

                          e.Row.Cells[0].BackColor = Color.Green;

                        }

}}}}

 

Please refer to the attached sample application for further reference.

 

Please get back to us if you need further assistance.

 

Regards,

Shanmugaraja



WebformSample_98767d5e.zip

Loader.
Live Chat Icon For mobile
Up arrow icon