By Mark Mailer
I recently read Scott Mitchell's article Creating a Row-Selectable DataGrid Control, which details how to create a custom DataGrid server control whose rows' background colors change when moused over and whose rows can be selected by clicking anywhere in the row. (You can see a live demo of Scott's control here.)
Rather than use Scott's custom control, I wanted a quick and easy way to add row-level highlighting when mousing over a
particular DataGrid in a particular ASP.NET page. My solution was to directly add
onmouseout attributes to the DataGrid's items in the
ItemDataBound event handler.
My code is used in an intranet, IE-only setting and has worked well. While not as robust as Scott's approach, it can be
quickly and easily implemented.
Anyway, the code for the DataGrid's
ItemDataBound event handler is provided below:
|Return to user tips...|