title: Adding CSS Class on RowDataBound
body: <p>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, <em>even if you append the CSS class</em>.</p>
  
  <p>Here's what I've got:</p>
  
  <pre><code>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 &lt;&gt; e.Row.Cells(2).Text And previousExpenseType.Length &gt; 0 Then
          e.Row.CssClass += "bottom-border"
        End If
  
        previousExpenseType = e.Row.Cells(2).Text
      End If
    End Sub
  </code></pre>
  
  <p><code>previousExpenseType</code> 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 <code>&lt;tr&gt;</code> element.</p>
  
  <p>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.</p>