title: Highlight row when select in Gridview
body: <p>I have a sub that displays years and buttons (3 columns), I manage to make the button change on RowDataBound, but what I also want is it to be highlighted,  I had <code>e.Row.BackColor = Color.FromArgb(0, 121, 139, 169)</code> but too hardcoded.</p>
  
  <p>my dataAdapter <code>Select FIN_ID, FIN_Name From FinancialYears Where GetDate() &gt;= FIN_DateStart And GetDate() &lt;= FIN_DateEnd</code></p>
  
  <p>VB code:</p>
  
  <pre><code>Protected Sub grdFinYear_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdFinYear.RowDataBound
          If e.Row.RowType = DataControlRowType.DataRow Then
  
              If grdFinYear.DataKeys(e.Row.RowIndex).Values("FIN_ID") = FIN_ID Then
                  If FIN_ID = e.Row.FindControl("hdnRecordID") Then
                      '    grdFinYear.SelectedIndex = e.Row.RowIndex
                      'End If
                      Dim activeButton As Button = e.Row.FindControl("btnSelect")
                      'e.Row.BackColor = Color.FromArgb(0, 121, 139, 169)
                      activeButton.CssClass = "ActionButtonsActiveYear"
                  Else
                      Dim makeActiveButton As Button = e.Row.FindControl("btnSelect")
                      'Dim button As Button = grdFinYear.Rows(i).FindControl("btnSelect")
                      'button.Text = "MAKE THIS YEAR ACTIVE"
                      'button.Width = 175
                      makeActiveButton.CssClass = "ActionButtonsMakeThisYearActive"
  
                  End If
              End If
      End Sub
  </code></pre>
  
  <p>in HTML I have </p>
  
  <pre><code>&lt;asp:HiddenField ID="hdnRecordID" runat="server" Value='&lt;%#Bind("FIN_ID") %&gt;' /&gt;
  </code></pre>