locked
Gridview Row Color using Javascript RRS feed

  • Question

  • User578059180 posted
     function SelectedRowColor(rowId)
         {
              var grid = document.getElementById("<%=Gridview1.ClientID%>"); 
              for (i=0;i<grid.rows.length;i++)
              {
                   grid.rows[i].style.backgroundColor = '#ffffff';
              }
              grid.rows[rowId].style.backgroundColor= 'Bisque';    
              return false;
         }

    On Code Behind

    Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
            e.Row.Attributes("onclick") = String.Format("javascript:SelectedRowColor({0});", e.Row.RowIndex)
        End Sub

    Monday, February 17, 2014 7:38 PM