标签:style blog http io ar color os sp java
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事件中添加处理逻辑了。
转自:http://xieycms.blog.163.com/blog/static/281213902010123105350751/
GridView点击行触发SelectedIndexChanged事件
标签:style blog http io ar color os sp java
原文地址:http://www.cnblogs.com/feilign/p/4124052.html