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事件中添加处理逻辑了。