- protected void gv_Main_RowDataBound(object sender, GridViewRowEventArgs e)
- {
- e.Row.Attributes.Add("id", "tr_" + e.Row.RowIndex.ToString());
- e.Row.Attributes.Add("onmouseover", "onmouse(/"" + "tr_" + e.Row.RowIndex.ToString() + "/")");
- e.Row.Attributes.Add("onmouseout", "mouseout(/"" + "tr_" + e.Row.RowIndex.ToString() + "/")");
- }
- <script language="javascript" type="text/javascript">
- var orgColor;
- function onmouse(rowId)
- {
- var myRow = document.getElementById(rowId);
- orgColor = myRow.style.backgroundColor;
- myRow.style.backgroundColor= "Red";
- myRow.align = "center";
- }
- function mouseout(rowId)
- {
- var myRow = document.getElementById(rowId);
- myRow.style.backgroundColor= orgColor;
- myRow.align = "left";
- }
- </script>