I'm trying to append a CSS class to a row on RowDataBound. I'm using the alternating css class property against the GridView, so I'm assuming this is applied on RowDataBound. If you assign a CSS class programatically to the CssClass property of the row within the RowDataBound event then the alternating row style css class is not applied, even if you append the CSS class.
Here's what I've got:
Protected Sub gvGeneral_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvGeneral.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
If previousExpenseType <> e.Row.Cells(2).Text And previousExpenseType.Length > 0 Then
e.Row.CssClass += "bottom-border"
End If
previousExpenseType = e.Row.Cells(2).Text
End If
End Sub
previousExpenseType
is just a String which I'm doing comparisons against. If the expense type changes, then I want to have a border applied to the bottom of the <tr>
element.
Any ideas how to get around this? It seems there's an event after RowDataBound that's applying the alternating row style css class to the row.