读书人

gridview变色的有关问题

发布时间: 2012-10-08 19:54:56 作者: rapoo

gridview变色的问题
代码如下

C# code
 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");            }        }      }

别的行都是正常的变颜色,可是第一行却没有放应是怎么回事啊?


[解决办法]
这样看看

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int i;
//执行循环,保证每条数据都可以更新
for (i = 0; i < GridView1.Rows.Count; i++)
{

//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='Aqua'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");

}
}

读书人网 >asp.net

热点推荐