zoukankan      html  css  js  c++  java
  • GridView点击行触发SelectedIndexChanged事件

    1、在<% @Page ...... %>指令中添加 EnableEventValidation="false"

    2、在RowDataBound事件中添加

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {      
            switch (e.Row.RowType)
            {
                case DataControlRowType.DataRow:
                    e.Row.Attributes["style"] = "cursor:hand";
                    #region   //点击行触发SelectedIndexChanged事件
                    PostBackOptions myPostBackOptions = new PostBackOptions(this);
                    myPostBackOptions.AutoPostBack = false;
                    myPostBackOptions.PerformValidation = false;
                    myPostBackOptions.RequiresJavaScriptProtocol = true; //加入javascript:头
                    String evt = Page.ClientScript.GetPostBackClientHyperlink(sender as GridView, "Select$" + e.Row.RowIndex.ToString());
                    e.Row.Attributes.Add("onclick", evt);
                    #endregion
                    break;
            }

        }

       3、在第一二步之后就可以在SelectedIndexChanging和SelectedIndexChanged事件中添加处理逻辑了。

    风雪七月花溅墨
  • 相关阅读:
    SaltStack
    python模块相关
    python optparse命令解析模块
    python ConfigParser模块 配置文件解析
    pssh 批量管理执行
    rsync+inotify 实现实时同步
    [译]17-spring基于java代码的配置元数据
    [译]16-spring基于注解的配置元数据
    [译]15-spring 自动装配
    [译]14-spring 集合元素的注入
  • 原文地址:https://www.cnblogs.com/bobo41/p/3363309.html
Copyright © 2011-2022 走看看