ASP.net 2.0 学习之001:鼠标移过GridView的行,前景色和背景色

80酷酷网    80kuku.com

  asp.net1、右击“GridView ”,选择“属性”--“事件”,选择“数据”下的“RowDataBound ”属性,双击它。

2、在“GridView1_RowDataBound ”方法下加入下列代码:

if (e.Row.RowType == DataControlRowType.DataRow)
...{
      
//鼠标移动到每项时颜色交替效果
   e.Row.Attributes.Add("OnMouseOut""this.style.backgroundColor='White';this.style.color='#003399'");
      e.Row.Attributes.Add(
"OnMouseOver""this.style.backgroundColor='#6699FF';this.style.color='#8C4510'");            

 }

3、保存所有文件,运行一下,发现鼠标在“GridView ”表格范围内移动时,每行的背景色发生变化,文字的颜色也变了。

4、这个小计巧很实用,可以很醒目地查看正在查看的记录。

5、以上资料来自 ,在此感谢!


分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: