Blog Stats
  • Posts - 99
  • Articles - 5
  • Comments - 30
  • Trackbacks - 111

 

Highlight DataGrid Row

or anything for that matter.

 

I was just reading this post http://geekswithblogs.net/dlussier/archive/2005/12/14/63142.aspx

There are 2 major problems with the solution presented.

1) it requires a recompile to change the colors

2) this should really be in a style sheet

Thus I present ... the style sheet implementation just set the datagridrow to be the right class.


in your css
.DataGridRow
{
background-color: black;
border: 0px;
behavior: url(/styles/rollover.htc);
}


in a .htc file

<PUBLIC:COMPONENT>
<PUBLIC:ATTACH EVENT="onmouseover" ONEVENT="Hilite()" />
<PUBLIC:ATTACH EVENT="onmouseout" ONEVENT="Restore()" />

<SCRIPT LANGUAGE="JScript">

var normalColor;

function Hilite() {
normalColor = currentStyle.backgroundColor;
runtimeStyle.backgroundColor = "#FFFF66";
}

function Restore() {
runtimeStyle.backgroundColor = normalColor;
}

</SCRIPT>
</PUBLIC:COMPONENT>


Feedback

# re: Highlight DataGrid Row

Gravatar This is a nice application of style sheet behaviors but be careful if you need to support multiple browers. 12/15/2005 11:02 AM | Nick Harrison

# re: Highlight DataGrid Row

Gravatar Nice code, but try it on a 1000 rows table. Result: very slow. Also it's not crossbrowser compatible. 5/7/2008 1:19 PM | Wad

Post a comment





 

Please add 7 and 2 and type the answer here:

 

 

Copyright © Greg Young