Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hghtlight Datagrid Row syntax error 1

Status
Not open for further replies.

ISPrincess

Programmer
Feb 22, 2002
318
US
In the RowDataBound event of my Datagrid, I have the following line of code:
Code:
e.Item.Attributes.Add("OnClick", "HighlightRow( this );")

in the HEAD of the page I have the following JS:
Code:
function HighlightRow(SRow)    
{
var oItem = SRow.style.backgroundColor;
if(oItem != 'LightSteelBlue')
{SRow.style.backgroundColor='LightSteelBlue';
// grdEmployees.SelectedItemStyle.BackColor
}else 
{SRow.style.backgroundColor='white'; 
//grdEmployees.ItemStyle.BackColor
}
}

When I click on the Datagrid Row, it does highlight it LightSteelBlue, but clicking again does not turn it back to white. There must be something obvious to an experienced JS developer in my syntax.

Can someone take a look, please?

Thanks!

PH
I was walking home one night and a guy hammering on a roof called me a paranoid little weirdo.
In morse code.
-Emo Phillips
 
Sorry, I did get it:
Code:
function HighlightRow(SRow)    
{
var oItem = SRow.style.backgroundColor;
if(oItem != '#b0c4de')
{SRow.style.backgroundColor='#b0c4de';
// grdEmployees.SelectedItemStyle.BackColor
}else 
{SRow.style.backgroundColor='#ffffff'; 
//grdEmployees.ItemStyle.BackColor
}
}

PH
I was walking home one night and a guy hammering on a roof called me a paranoid little weirdo.
In morse code.
-Emo Phillips
 
You can cut down on some lines of code:

Code:
function HighlightRow(SRow) {
    var bg = SRow.style.backgroundColor;
    SRow.style.backgroundColor = ( bg == 'LightSteelBlue' ) ? 'white' : 'LightSteelBlue';
}

And you should initially set the background-color of each row.

*cLFlaVA
----------------------------
[tt]insert funny quotation here.[/tt]
 
sorry, i meant star goes to clfava.

but thanks to andy too.


PH
I was walking home one night and a guy hammering on a roof called me a paranoid little weirdo.
In morse code.
-Emo Phillips
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top