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

Alternating color for DataBoundGrid

Hi,

I want to have alternating colors for DataBoundGrid, I don't see any property. Is there a way?

Thanks,
Dheeraj

1 Reply

AD Administrator Syncfusion Team November 27, 2006 07:04 AM UTC

Hi Dheeraj,

You can handle the PrepareViewStyleInfo event and set the backcolor for the alternate rows in a grid. Here is a code snippet to show this.

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if( e.RowIndex > 0 && e.ColIndex > 0 )
{
if( e.RowIndex % 2 == 0)
e.Style.BackColor = Color.Gray;
else
e.Style.BackColor = Color.AliceBlue ;
}
}

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon