GridView鼠标移动到哪行,哪行的背景色改变

来源:互联网 发布:让淘宝客户加微信话术 编辑:程序博客网 时间:2024/05/03 07:22
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='#ffcc33'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");



protected void gridList_RowDataBound(object sender, GridViewRowEventArgs e)    {                   //如果是绑定数据行         if (e.Row.RowType == DataControlRowType.DataRow)        {            //鼠标经过时,行背景色变             e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#E6F5FA'");            //鼠标移出时,行背景色变             e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");//行事件,千万不要写循环,本身ROWDATABOUND就是循环的            e.Row.Attributes.Add("dbclick", "可直接写JS代码也可写JS函数,然后前台设置JS函数");//列事件,可以循环实现多列            e.Row.Cells[1].Attributes.Add("onclick", "showedit(this)");            e.Row.Cells[3].Attributes.Add("onclick", "showedit(this)");        }    }




0 0
原创粉丝点击