首页 > 其他 > 详细

gridview 单击行时如何让SelectedIndexChanging事件响应

时间:2014-07-25 18:59:02      阅读:461      评论:0      收藏:0      [点我收藏+]

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

gridview 单击行时如何让SelectedIndexChanging事件响应,布布扣,bubuko.com

gridview 单击行时如何让SelectedIndexChanging事件响应

原文:http://www.cnblogs.com/future/p/3868019.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!