弱问datagird
datagird绑定显示表1,显示的每行后面有个编辑和删除按钮,编辑和删除功能都实现了。我希望点删除按钮后,出现个确认删除的提示对话框,如果选确认则删除,选取消则返回。请问这个对话框怎么实现?
<asp:datagrid id= "DataGrid1 " style= "Z-INDEX: 103; LEFT: 24px; POSITION: absolute; TOP: 216px "
runat= "server " Height= "208px " Width= "448px " HorizontalAlign= "Justify " PageSize= "5 " AutoGenerateColumns= "False ">
<Columns>
<asp:BoundColumn DataField= "proname " HeaderText= "程序名称 "> </asp:BoundColumn>
<asp:BoundColumn DataField= "prover " HeaderText= "版本 "> </asp:BoundColumn>
<asp:ButtonColumn Text= "详细 " CommandName= "Select "> </asp:ButtonColumn>
<asp:ButtonColumn Text= "删除 " CommandName= "Delete "> </asp:ButtonColumn>
<asp:EditCommandColumn ButtonType= "LinkButton " UpdateText= "更新 " CancelText= "取消 " EditText= "编辑 "> </asp:EditCommandColumn>
</Columns>
</asp:datagrid>
private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string key=DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
DeleteTable(key); //根据表的主键值删除该行
}
------解决方案--------------------在ItemDataBound函数里面写
if (e.Row.FindControl( "Delete ") != null)
((LinkButton)e.Row.FindControl( "Delete ")).Attributes.Add( "OnClick ", "return confirm( '您确认要删除此项记录吗? '); ");