protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int i;
for (i = 0; i < GridView1.Rows.Count; i++)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='Aqua'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
}
以上是我改变GridView颜色的代码,可是调试的时候,结果并不完全对,当选中第一行数据的时候,颜色没有变化,从第二行开始颜色会发生变化,求解???GridView改变GridView选中行的颜色asp.net
{
int i;
for (i = 0; i < GridView1.Rows.Count; i++)
{
//首先判断是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='Aqua'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
}
以上是我改变GridView颜色的代码,可是调试的时候,结果并不完全对,当选中第一行数据的时候,颜色没有变化,从第二行开始颜色会发生变化,求解???GridView改变GridView选中行的颜色asp.net
解决方案 »
- 我电脑上又有sql2000,又有sql2005,为什么2005连不上数据库?
- 如何将Gridview 的选中行通过邮件发送??急!!求帮助~~
- 前台页面链接问题
- dorpdownlist下拉列表绑定SQL记录集问题.解决速度上分!在线等!急!
- Datalist 事件只响应一次
- 怎么在.CS里面调用applet属性???????????
- 一个复杂的正则表达的问题!!!
- 对话框问题
- 大家给一些思路,自己做一个类似dataset的数据集,帮帮忙啦
- 怎样根据连接来,选择数据???
- ExtJS一段代码报错,无法获取未定义或 null 引用的属性“hasOwnProperty”
- 关于ewebeditor的问题
里面还要用
for (i = 0; i < GridView1.Rows.Count; i++)?这不是画蛇添足吗?
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='Aqua'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c"); }
}