Category / Section
What is the equivalent property for the "AlternateRowColor" in the GridDataBoundGrid?
1 min read
You can color alternate rows in the GridDataBoundGrid by using the PrepareViewStyleInfo event.
C#
void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) { // Check for alternate rows. if (e.RowIndex > 0 && e.ColIndex > 0 && e.RowIndex % 2 == 1) e.Style.BackColor = Color.LightBlue; }
VB
Private Sub gridDataBoundGrid1_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As GridPrepareViewStyleInfoEventArgs) ' Check for alternate rows. If e.RowIndex > 0 AndAlso e.ColIndex > 0 AndAlso e.RowIndex Mod 2 = 1 Then e.Style.BackColor = Color.LightBlue End If End Sub
Figure 1: Grid with Alternate Row Color
Sample Link: