网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 gridview 行选添加颜色和事件
内容
    在gridview 列表中,需要添加如下效果,如果经过时变色,移开时还原成以前的颜色,行选中时通过加深色,从而知道选中了哪行
    在gridview 列表中,需要添加如下效果,如果经过时变色,移开时还原成以前的颜色,行选中时通过加深色,从而知道选中了哪行,特别是列表数据比较多的时候,标志很重要,同时触发选中行事件,那么如何 行选中加颜色,同时也出发我们事件了?如果我们通入 e.row.attributes.add(onclick, 绑定两次,发现只能触发其中的一个,其实可以把另个放到一个里面
    下面是具体的例子:
    代码如下:
    protected void editgridview_rowdatabound(object sender, gridviewroweventargs e)
    {
    if (e.row.rowtype== datacontrolrowtype.datarow)
    {
    //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色
    e.row.attributes.add(onmouseover, currentcolor=this.style.backgroundcolor;this.style.backgroundcolor='inactivecaptiontext',this.style.fontweight
    ='';this.style.cursor='hand';);
    //当鼠标离开的时候 将背景颜色还原的以前的颜色
    e.row.attributes.add(onmouseout, this.style.backgroundcolor=currentcolor,this.style.fontweight='';);
    //当鼠标单击时,加深色标志
    e.row.attributes.add(onclick, setvalue();if(window.oldtr!=null){window.oldtr.runtimestyle.csstext='';}this.runtimestyle.csstext='background-color:#e6c5fc';window.oldtr=this);
    }
    }
    js代码:
    代码如下:
    <script type=text/javascript >
    function setvalue() {
    alert('行单击事件,同时变色');
    }
    </script>
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/19 5:07:13