编写javascript以在gridview rowdeleting事件中确认删除
我正在从 gridview 中删除一行,我已使用 gridview 的默认删除命令字段。单击时,将触发 gridview 行删除命令并删除所选行。到现在为止一切都很好。
但在删除该行之前,我需要向用户设置确认消息。单击“确定”按钮后,该行应该被删除,否则不会(单击“取消”按钮时)。
我的代码为;
return confirm('Are you sure to delete?');
但是,如果有一个链接按钮(而不是命令字段),则效果很好,因为我可以轻松地在链接按钮的 OnClick 事件上编写内容,并且可以在 Gridview RowDataBound 事件中添加属性。
对于命令的字段删除按钮同样如何工作?请指导!
谢谢!
I am deleting a row from gridview for which i have used gridview's default delete command field. On clicking, the gridview row deleting command gets fired and the selected row gets deleted. All good till now.
But before the row gets deleted, i need to set confirmation message to user. On clicking of OK button the row should get deleted else not (on click of cancel button).
I have the code as;
return confirm('Are you sure to delete?');
But this works fine if there is a linkbutton (instead of command field) as i could easily write on OnClick event of linkbutton and could add the attributes in Gridview RowDataBound event.
How the same would work for command's field delete button? Please guide!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
本文介绍了如何完全满足您的需要:
http://www.codeproject.com/ KB/webforms/Gridview_Delete_confirmLS.aspx
这是您需要执行此操作的代码:
This article explains how to do exactly what you need:
http://www.codeproject.com/KB/webforms/Gridview_Delete_confirmLS.aspx
And here is the code you need to do it:
这是您可以使用的代码......
Here is code which you can use....
试试这个。
比我最初预期的要脏得多。最好使用
asp:TemplateField
:)请注意我的
ButtonType="Button"
Try this.
Much more dirty than I originally anticipated. Better to use a
asp:TemplateField
:)Please note that my
ButtonType="Button"