Gridview highlighting does not work
Hi.
I have a gridview, and when a user clicks a row, the row should be highlighted. If the user clicks another row, this newly clicked row should be highlighted, but the other row should loose its highlighting. That means, that only one row can be highlighted at a time.
I´ve seen several solutions for this, that were way too overkill.
So instead I have this solution:
- $("#MainContent_GridViewResults tbody tr").click(function () {
$("#MainContent_GridViewResults tbody tr").each(function () {
$(this).addClass("clear");
})
$(this).addClass("select");
})
As you can see, when a row is clicked, I try to remove all the rows highlighting, and only assign the highlight to the row I just clicked.
The problem with this code is that all of the rows gets the 'clear' class assigned (as they should), but the row I just clicked doesent get the 'select' class assigned.
I.e. $(this).addClass("select"); is kind of ignored..
How come?
(If I remove the each function, the row I just clicked gets the 'select' class assigned just fine...)
Thanks alot!