注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 获取当前页面路径,实现权..
 帮助

ASP.NET基础教程-DataGrid表格控件-利用ItemDataBound事件实现鼠标移动到控件的某一行时改变该行的背景色


版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://chenxing.blog.51cto.com/240526/45634
private void DataGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
    if(e.Item.ItemType==ListItemType.Item ||
                     e.Item.ItemType ==ListItemType.AlternatingItem)
 {
     e.Item.Attributes.Add("onmouseover",
                   "currentcolor=this.style.backgroundColor,this.style.backgroundColor='#ffff00'");
    e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
 }
}




    文章评论
 
 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: