天天看點

ASP.NET2.0下為GridView添加滑鼠滑過(onmouseover、onmouseout)的方

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

    {

        //判定目前的行是否屬于datarow類型的行

        if (e.Row.RowType == DataControlRowType.DataRow)

        {

            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='yellow',this.style.fontWeight='';");

            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");

            e.Row.Attributes.Add("onclick", "this.style.backgroundColor='#99cc00'; this.style.color='buttontext';this.style.cursor='default';");

        }

    }