zoukankan      html  css  js  c++  java
  • GridView改变行的颜色(二)

    1.增加GridViewGVSelect_RowDataBound事件
    protectedvoid GVSelect_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //当鼠标停留时更改背景色
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#8EC26F'");
                //当鼠标移开时还原背景色
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                //设置悬浮鼠标指针形状为"小手"
                e.Row.Attributes["style"] = "Cursor:hand";
     
                //单击/双击 事件
                e.Row.Attributes.Add("OnClick", "ClickEvent('" + e.Row.Cells[0].Text + "')");
                //注:OnClick参数是指明为鼠标单击时间,后个是调用javascriptClickEvent函数
            }
    }
    2在页面的HTML里添加javascript函数,用来响应鼠标点击事件,因为ASP客户端不能主动调用服务端的函数,我在这里添加一个LinkButton,将其text设置为空,然后在ClickEvent(cId)函数中,调用这个LinkButton的单击事件。
    <scriptlanguage="javascript">
        function ClickEvent(cId)
        {
            //调用LinkButton的单击事件,btnBindDataLinkButtonID
            document.getElementById("btnBindData").click();
        }
    </script>
    3.添加LinkButton的响应事件
       protectedvoid btnBindData_Click(object sender, EventArgs e)
    {
             //在这里对你需要的数据信息进行输出
             SetClientInfo();//我的处理函数
    }
    GridView鼠标停留变色和单击处理事件,当鼠标在GridView的行上停留时,将该行变色,当单击该行时,做相应处理
  • 相关阅读:
    复制功能的实现
    SDWebImage从缓存中获取图片
    修改屏幕亮度
    使用系统的CoreLocation定位
    button设置边宽和圆角
    在日期选择轮中选择的时间转换成年龄
    字符串与数组互转
    使用ASI传递post表单..参数是数组
    点击头像单独把图片拉取出来.然后再次点击回到初始效果
    Xcode svn import项目 上传.a文件(静态库)
  • 原文地址:https://www.cnblogs.com/zhangpengshou/p/863701.html
Copyright © 2011-2022 走看看