您的位置:首页 > 其它

在DataGrid中,使鼠标到达的行和列显示不同的颜色

2005-08-16 22:32 281 查看
核心代码:

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");

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐