none
asp.net确认对话框 RRS feed

  • 问题

  • 我在gridview中有一个删除事件,但我想确认一下是否删除,用的confirm确认对话框,怎么获取返回值,做了判断之后再删除与否!谢谢
    2010年8月14日 12:38

答案

  • 你好:

    你需要在行数据绑定事件中给每行的删除按钮绑定一个客户端事件。

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
      LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1"); 
      l.Attributes.Add("onclick", "javascript:return " +
      "confirm('Are you sure you want to delete this record " +
      DataBinder.Eval(e.Row.DataItem, "CategoryID") + "')"); 
     }
    }

    http://www.cnblogs.com/Aricc/archive/2008/11/26/1341382.html

    希望对你有所帮助。

    2010年8月16日 5:49
    版主

全部回复