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】是指被删除的数据信息的【删除】按钮所在的位置。
代码;
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】是指被删除的数据信息的【删除】按钮所在的位置。
浙公网安备 33010602011771号