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

相关文章:

  • 2021-12-12
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2021-10-14
  • 2021-06-10
猜你喜欢
  • 2021-08-02
  • 2022-12-23
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案