PDA

View Full Version : select/unselect row?


Techno
06-28-2007, 07:29 AM
I have a gridview in ASP.NET. I want to be able to select a row onclick. I have done this and works fine - the selection is done on clientside (javascript)

what I would like to do now is to restore back the color of the previous row when the user clicks on another row. how is this possible?

current code I have for selecting a row:

function setMouseClick(element, currentRowIndex)
{
//I would imagine this comment would be the one to use to restore the previous rows
previousRowIndex = currentRowIndex
oldgridSelectedColor = element.style.backgroundColor;
element.style.backgroundColor = '#5A7EBF';

}

I want to be able to restore back the previous row color

Techno
06-28-2007, 07:55 AM
ha! figured it out ;)

function setMouseClick(element, currentRowIndex)
{
this.grid = element;
this.DoRestorePreviousRowColor(this.previousRowIndex);
this.previousRowIndex = currentRowIndex;

//this.onGridViewRowSelected(currentRowIndex);
oldgridSelectedColor = element.style.backgroundColor;
element.style.backgroundColor = '#5A7EBF';

}

function DoRestorePreviousRowColor(previousRowIndex)
{
document.getElementById('row' + previousRowIndex).style.backgroundColor = oldgridSelectedColor;
}