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事件了。

  • 相关阅读:
    EffectiveJava-4
    EffectiveJava-3
    EffectiveJava-2
    EffectiveJava-1
    jar包下载
    SpringBoot踩坑日记
    Spring全家桶——SpringBoot之AOP详解
    Spring全家桶——SpringBoot渐入佳境
    Spring全家桶一一SpringBoot与Mybatis
    SpringBoot2.x【一】从零开始环境搭建
  • 原文地址:https://www.cnblogs.com/future/p/3868019.html
Copyright © 2011-2022 走看看