sd_dracula
sd_dracula

Reputation: 3896

asp.net listview highlight row on click

I know how to set up listview to highlight a row when you click a link, image, etc but I am just wondering if it is possible to set it up to highlight a row when you click on any of its cells, not just on a predefined control.

Is that possible?

I way around it would be to setup onclick of each <td> but no idea how to reset the background colour when you click on another cell.

Upvotes: 0

Views: 2100

Answers (1)

John Koerner
John Koerner

Reputation: 38087

You could use Jquery on the client side:

$("#myTable tr").click( function () 
{
   $("#myTable tr").each(function () { $(this).removeClass("selected")}); 
   $(this).addClass("selected"); 
});​

An example fiddle:

http://jsfiddle.net/9pmcA/26/

Upvotes: 4

Related Questions