当前位置:首页 > 网站技术 > ASP.NET

DataGrid中使鼠标到达的行显示不同的颜色

...

核心代码:


private void grdCustomer_ItemDataBound(object sender,
         System.Web.UI.WebControls.DataGridItemEventArgs e)
{
     if(e.Item.ItemType == ListItemType.AlternatingItem ||
              e.Item.ItemType == ListItemType.Item )
     {
        e.Item.Attributes.Add("onmouseover", "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#C8F7FF'");
        e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=this.oldcolor");
        for (int i = 0; i< grdCustomer.Columns.Count; i++ )
        {
            e.Item.Cells[i].Attributes.Add("onmouseover",
          "this.oldcolor=this.style.backgroundColor;this.style.backgroundColor='#99ccff'");
            e.Item.Cells[i].Attributes.Add(
                       "onmouseout", "this.style.backgroundColor=this.oldcolor");
         }
     }
}

继续阅读
无组件Ajax效果实现
ASP.NET中Popup控件的使用方法
ASP.NET开发要抛弃ASP旧习和破烂
ASP.NET网站取得访客信息方法
ASP.NET中URL传参数出现乱码解决方法
ASP.NET2.0中文验证码的实现代码
ASP.NET防止用户多次登录的方法
ASP.NET2.0的URL映射的实现方法
Remoting超时问题及初步解决方法
发表评论

昵称:
最新评论
暂时没有评论!