gridview中的确认框删除 [英] Confirmation box in gridview delete

查看:67
本文介绍了gridview中的确认框删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#在asp.net 3.5版本中完成我的项目.
我有一个带删除按钮的gridview.单击删除按钮后,我要弹出一个确认框,如果单击是"按钮,则数据库中相应值的状态应更改为"0".我在gridview中使用了一个javascript函数和模板字段.我收到确认框,但是单击是"按钮时,发生错误,原因是"

I''m doing my project in asp.net 3.5 version using C#.
I''m having a gridview with delete buttons. When the delete button is clicked I want to pop up a confirmation box and if the ''Yes'' button is clicked, status of the corresponding value should be change as ''0'' in database. I have used one javascript function and template field in gridview. I''m getting the confirmation box, but when ''Yes'' button is clicked an error is occuring as "

Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.


.

我该怎么解决?
有人请帮助我...

感谢


".

How can I solve it?
Anybody please help me...

thanks

推荐答案

尝试此
if (!IsPostBack)

  {
      //Your code for Bind data
   }


出于安全目的,EnableEventValidation功能验证回发或回调事件的参数源自最初呈现它们的服务器控件.
这是bcoz,可能会找到<>之类的标签.回发后


For security purposes,EnableEventValidation feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.
This is bcoz it might found some tag like <> after postback


,您可以使用以下代码对删除按钮进行确认
you can use following code for giving confirmation on delete button
<Columns>
      <asp:TemplateField ShowHeader="False">
             <ItemTemplate>
 <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" OnClientClick="javascript : return confirm('Do you really want to \n Delete?');">                                                
 </asp:LinkButton>
   </ItemTemplate>
      </asp:TemplateField>
 </Columns>


这篇关于gridview中的确认框删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆