GridView 当鼠标经过改变颜色

lxl_sports 2009-10-18 10:24:21

GridView1_RowDataBound 事件里


if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add( "onmouseover ", "this.style.backgroundColor= '#E8F4FF ';this.style.color= 'red ' ");
e.Row.Attributes.Add( "onmouseout ", "this.style.backgroundColor= '#ffffff ';this.style.color= '#000000 ' ");

e.Row.Attributes.Add( "onclick ", "javascript:window.location.href= 'admin_admin_ok.aspx?id= " + sysID + " '; ");
e.Row.Attributes[ "style "] = "Cursor:hand ";



但是这个不行啊 不改变颜色 那位高手给指点一下
...全文
191 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
a657987496 2011-05-20
  • 打赏
  • 举报
回复
Mark
ririu 2009-12-13
  • 打赏
  • 举报
回复
刚正巧也在学这个.呵呵
phf0313 2009-10-18
  • 打赏
  • 举报
回复
网上有个文档不错,介绍了gridview几种常用的操作,可以在网上下一个做为参考。
名字好像叫“gridview 18中操作”,好像CSDN下载频道就有。
Adechen 2009-10-18
  • 打赏
  • 举报
回复
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E8F4FF'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");

}
}
可以参考gridview 72般绝技
happy664618843 2009-10-18
  • 打赏
  • 举报
回复
e.Row.Attributes.Add("onmouseover","this.style.currentColor=this.style.backgroundColor; this.style.backgroundColor='#000000'")
wuyq11 2009-10-18
  • 打赏
  • 举报
回复
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E8F4FF'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");

}
}


protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onMouseOver", "SetNewColor(this);");
e.Row.Attributes.Add("onMouseOut", "SetOldColor(this);");
}
}
var _oldColor;
function SetNewColor(source)
{
_oldColor=source.style.backgroundColor;
source.style.backgroundColor='#E8F4FF';
}
function SetOldColor(source)
{
source.style.backgroundColor=_oldColor;
}


puzhichen 2009-10-18
  • 打赏
  • 举报
回复
感觉这是GridView最方便的一个效果!
代码直接复制!
春天的气息 2009-10-18
  • 打赏
  • 举报
回复
上面的没显示全,对不起呀!



//双击GridView的OnRowDataBound事件;
//在后台的GridView1_RowDataBound()方法添加代码,最后代码如下所示:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#C0C0C0'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}

春天的气息 2009-10-18
  • 打赏
  • 举报
回复

//双击GridView的OnRowDataBound事件;
//在后台的GridView1_RowDataBound()方法添加代码,最后代码如下所示:

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#C0C0C0'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}





sohighthesky 2009-10-18
  • 打赏
  • 举报
回复
把最后一个设置鼠标样式 的先去掉看看
sohighthesky 2009-10-18
  • 打赏
  • 举报
回复
除了#000000后面多了个空格没看出什么问题
wjn161 2009-10-18
  • 打赏
  • 举报
回复
Mark
zhouchen595388095 2009-10-18
  • 打赏
  • 举报
回复
定4楼的 我相信 一定行的最好是vs2008

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧