Gridview 删除弹出确认框

   定义在Gridveiw控件的RowDataBound 事件下,使用Attributes.Add方法实现。
代码;
      protected void gridview1_RowDataBound(object sender,GridviewRowEventArgs e)
      {
            if(e.Row.RowType==DataControlRowType.DataRow)
            {
                  (LinkButton)e.Row.Cell[4].Controls[0].Attributes.Add("onclick","return confirm("确认要删除吗?")");
            }
      }
说明:Gridview控件的RowDataBound事件是在gridview控件将数据行绑定到数据时发生的。
         代码中的e.Row.Cells【4】是指被删除的数据信息的【删除】按钮所在的位置。
posted on 2009-08-06 11:00  晴天1848  阅读(201)  评论(0)    收藏  举报