日期:2014-05-20  浏览次数:20417 次

如何实现GridView中删除数据时弹出确认窗口!!!!!!!!!
如何实现GridView中删除数据时弹出确认窗口

在线等..

------解决方案--------------------
添加一个脚本事件阿,confirm...
------解决方案--------------------
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID= "DeleteLinkButton " runat= "server " CommandName= "DELETE " OnClientClick= "javascript : return window.confirm( 'Are you sure you want to delete this item? '); " ImageUrl= "~/images/TimeStudy/Buttons/Del.gif " ToolTip= "Delete Employee "/>
</ItemTemplate>
<ItemStyle Width= "5% " />
</asp:TemplateField>
------解决方案--------------------
在Page_Load事件中添加如下代码:

{
((Button)sender).Attributes.Add( "OnClick ", "javascript: return confirm( '确认删除? '); ");
}
------解决方案--------------------
<asp:CommandField ShowDeleteButton= "True " DeleteText= " <div id=&quot;del&quot; onclick=&quot;JavaScript:return confirm( '确定要删除此记录吗? ')&quot;> 删除 </div> " />
------解决方案--------------------
参照:
((ImageButton)e.Item.FindControl( "Ib_Delete ")).Attributes.Add( "onclick ", "return confirm( '确认删除? '); ");
------解决方案--------------------
vs2003的在OnItemDataBound事件中,
添加:
if(e.Item.ItemType==ListItemType.AlternatingItem || e.Item.ItemType==ListItemType.Item)
{
Button btn=(Button)e.Item.FindControl( "按钮的ID ");
btn.Attributes.Add( "OnClick ", "javascript: return confirm( '确认删除? ') ");
}

vs2005的在OnRowDataBound事件中,
添加:
if(e.Row.RowType==DataControlRowType.DataRow)
{
Button btn=(Button)e.Item.FindControl( "按钮的ID ");
btn.Attributes.Add( "OnClick ", "javascript: return confirm( '确认删除? ') ");
}
------解决方案--------------------
如果用imagebutton找到OnClientClick属性,在里面加入
return confirm( '确认删除? ')