Posted By

krisdb on 07/25/08


Tagged

c-sharp


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


Gridview MouseOver Color


 / Published in: C#
 

  1. protected void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
  2. {
  3. DataControlRowType rtype = e.Row.RowType;
  4.  
  5. if (rtype == DataControlRowType.DataRow && rtype != DataControlRowType.Footer && rtype != DataControlRowType.Separator && rtype != DataControlRowType.Header && rtype != DataControlRowType.Pager)
  6. {
  7. e.Row.Attributes.Add("onmouseover", "Highlight(this,'#DCEDFF');");
  8. e.Row.Attributes.Add("onmouseout", "resetColorRows('#ffffff','#eeeeee');");
  9. }
  10. }
  11.  
  12. <script type="text/javascript">
  13. function Highlight(row,color)
  14. {
  15. row.style.backgroundColor=color;
  16. }
  17.  
  18.  
  19. function resetColorRows(color1,color2)
  20. {
  21. var bgColor;
  22.  
  23. t = document.getElementsByTagName("tr");
  24.  
  25. for (var i=1; i<t.length; i++)
  26. {
  27. if ((i % 2) == 1)
  28. bgColor = color1;
  29. else
  30. bgColor = color2;
  31.  
  32. t[i].style.backgroundColor = bgColor;
  33. }
  34. }
  35. </script>

Report this snippet  

You need to login to post a comment.