zoukankan      html  css  js  c++  java
  • 给GridView添加【单击】、【双击】事件的解决方案

        #region 行绑定事件
        /// <summary>
        /// 行绑定事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string keyCode = e.Row.Cells[0].Text;//得到当前行的主键值
                ((LinkButton)(e.Row.Cells[14].Controls[1])).Attributes.Add("OnClick", "win=window.showModalDialog('EditAlarm.aspx?code="+keyCode+"','open','center:yes;scroll:yes;dialogWidth:400px;dialogHeight:580px;resizable:yes;');");
    //双击事件

    e.Row.Attributes.Add("OnDblClick", "if(this.backgroundColor!='#ffccaa'){this.style.backgroundColor='#ffccaa';win=window.showModalDialog('tbAlarmWeightImage.aspx?KeyCode=" + keyCode + "','open','center:yes;scroll:yes;dialogWeight:480px;dialogHeight:550px;resizable:yes;');return false};if(this.backgroundColor='#ffccaa'){this.backgroundColor='#ffffff';}");

                //添加单击事件并设置延迟事件
                e.Row.Attributes["onclick"] = String.Format("javascript:setTimeout(\"if(dbl_click){{dbl_click=false;}}else{{{0}}};\", 200);", ClientScript.GetPostBackEventReference(gridview, "Select$" + e.Row.RowIndex.ToString(), true));
            }
        }
        #endregion

    作者:江宁织造
    博客:http://www.cnblogs.com/wgx0428/
  • 相关阅读:
    jvm字节码简介
    Class类文件结构
    springboot 配置webservice接口
    jdk(1.8)命令行工具(二)
    springboot集成JsonRpc2.0
    jdk命令行工具(一)
    linux安装spark-2.3.0集群
    linux安装scala环境
    [机器学习实践] 针对Breast-Cancer数据集
    mac下 selenium + python 配置和入门
  • 原文地址:https://www.cnblogs.com/wgx0428/p/2408326.html
Copyright © 2011-2022 走看看