重写render,利用ClientScript,在客户端注册select,回发到服务器,触发服务器端的行选择事件。

View Code 原文地址 http://edu.cnzz.cn/NewsInfo/28278.aspx#
 1     //重写render,利用ClientScript,在客户端注册select,回发到服务器,触发服务器端的行选择事件。
 2   protected override void Render(HtmlTextWriter writer)
 3     {
 4         foreach (GridViewRow row in GridView1.Rows)
 5         {
 6            if (row.RowType == DataControlRowType.DataRow)
 7            {
 8              row.Attributes["onclick"= ClientScript.GetPostBackEventReference(GridView1, "Select$" + row.RowIndex.ToString(), true);
 9                row.Attributes["style"= "cursor:pointer";
10                row.Attributes["title"= "单击选择行";
11            }
12         }
13         base.Render(writer);
14     }
posted @ 2011-06-20 16:07  DR19  阅读(246)  评论(0编辑  收藏  举报