zoukankan      html  css  js  c++  java
  • gridview 单击行时如何让SelectedIndexChanging事件响应

    在gridview控件上单击行的时候,是不触发SelectedIndexChanging事件的,那么想要单击时触发SelectedIndexChanging事件时怎么做呢?

    我是这样做的:

    在gridview的行绑定事件

    RowDataBound(object sender, GridViewRowEventArgs e) 中写入


            if (e.Row.RowType == 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
            }

    加上这些之后,在点击行时就可以触发SelectedIndexChanging事件了。

  • 相关阅读:
    minecraft我的世界汇总网站
    扫雷网页版
    扫雷模型(非完全一样)
    设计模式-策略模式
    hadoop(2)hadoop配置
    hadoop(1)入门
    Openssl
    加密解密
    信息安全通信
    Web
  • 原文地址:https://www.cnblogs.com/future/p/3868019.html
Copyright © 2011-2022 走看看