hi every one i am trying to change gridview row color onclick event i used following javascript for row color changing
var previousRow;
function ChangeRowColor(row) {
//If last clicked row and the current clicked row are same
if (previousRow == row)
return; //do nothing
//If there is row clicked earlier
else if (previousRow != null)
//change the color of the previous row back to white
document.getElementById(previousRow).style.backgroundColor = "#ffffff";
//change the color of the current row to light yellow
document.getElementById(row).style.backgroundColor = "#ffffda";
//assign the current row id to the previous row id
//for next row to be clicked
previousRow = row;
}
i called javascript in c# like below
protected void GridViewCompliants_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "javascript:ChangeRowColor('" + e.Row.ClientID + "')");
}
}
this above written code is not working pls help me thanks in advance