主题:GridView删除行时如何提示?
如题,在GridView添加了删除的LinkButton,但想在点击时出现对话框以确定是否删除,如果点击确定才删除,否则点击取消则不做!
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType ==System .Web .UI .WebControls.DataControlRowType .DataRow )
{
((LinkButton)e.Row.Cells[7].Controls[1]).Attributes.Add("onclick", "return confirm('确认删除吗?');");
}
}
我用了如上语句,可以弹出对话框,但是不管点击确定还是取消都会去执行protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)!所以和没有添加的效果是一样的。请问这是怎么回事?
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType ==System .Web .UI .WebControls.DataControlRowType .DataRow )
{
((LinkButton)e.Row.Cells[7].Controls[1]).Attributes.Add("onclick", "return confirm('确认删除吗?');");
}
}
我用了如上语句,可以弹出对话框,但是不管点击确定还是取消都会去执行protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)!所以和没有添加的效果是一样的。请问这是怎么回事?