给GridView里的行加上鼠标滚动效果

来源:互联网 发布:网络4g十是什么意思 编辑:程序博客网 时间:2024/04/30 05:42
 
  1. protected void gv_Main_RowDataBound(object sender, GridViewRowEventArgs e)
  2.         {
  3.             e.Row.Attributes.Add("id""tr_" + e.Row.RowIndex.ToString());
  4.             e.Row.Attributes.Add("onmouseover""onmouse(/"" + "tr_" + e.Row.RowIndex.ToString() + "/")");
  5.             e.Row.Attributes.Add("onmouseout""mouseout(/"" + "tr_" + e.Row.RowIndex.ToString() + "/")");
  6.         }

 

  1. <script language="javascript" type="text/javascript">
  2. var orgColor;
  3. function onmouse(rowId)
  4. {
  5.     var myRow = document.getElementById(rowId);
  6.     orgColor = myRow.style.backgroundColor;
  7.     myRow.style.backgroundColor= "Red";
  8.     myRow.align = "center";
  9. }
  10. function mouseout(rowId)
  11. {
  12.     var myRow = document.getElementById(rowId);
  13.     myRow.style.backgroundColor= orgColor;
  14.     myRow.align = "left";
  15. }
  16. </script>
原创粉丝点击