int j;
//执行循环,保证每条数据都可以更新
for (j = 0; j <= GridView2.Rows.Count; j++)//行变色
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F5DBDC'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
//执行循环,保证每条数据都可以更新
for (j = 0; j <= GridView2.Rows.Count; j++)//行变色
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F5DBDC'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
网格视图行交互效果
本文介绍了一种在网格视图中实现行交互效果的方法,包括鼠标悬停时改变背景颜色及移开后恢复原色的功能。通过简单的C#代码实现了这一效果,增强了用户体验。
201

被折叠的 条评论
为什么被折叠?



