网格视图删除事件不是火 [英] grid view delete event is not fire

查看:106
本文介绍了网格视图删除事件不是火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在使用Gridview,我想在我的Gridview行上进行DELETE操作..但是我点击网格视图删除图像按钮就会抛出这样的异常..



无效的回发或回调参数。使用< pages enableeventvalidation =true>启用事件验证在配置或<%@ Page EnableEventValidation =true%>在一个页面中。出于安全考虑,此功能可验证回发或回调事件的参数是否来自最初呈现它们的服务器控件。如果数据有效且符合预期,请使用ClientScriptManager.RegisterForEventValidation方法注册回发或回调数据以进行验证。





代码..

Hi guys
I am working on Gridview and i wanna do DELETE Operation on my Gridview row..but i click on grid view delete image button it throws exception like this..

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.


code..

protected void gdProducts_RowDeleting(object sender, GridViewDeleteEventArgs e)
       {
           try
           {
               objBusinessUI.ProductID = Int32.Parse(gdProducts.DataKeys[e.RowIndex].Value.ToString());
               objBusinessUI.UpdatedBy = "Admin";
               objBusinessUI.UpdatedOn = DateTime.Now;
               string StrMsg = objDataUI.DeleteProduct(objBusinessUI);
               if (StrMsg=="SUCCESS")
               {

               }
               else
               {

               }
           }
           catch (Exception ex)
           {
               log.Error(System.Reflection.MethodBase.GetCurrentMethod().ToString() + ex.StackTrace);
           }
       }







源代码。用于iamge按钮gridview






Source code.For iamge button gridview

<ItemTemplate:ImageButton ID="imgDelete";  runat="server" CommandName="Delete" ImageUrl="~/Images1/edit_delete.jpeg";  önClientClick="return confirm('Are you sure you want to delete selected record ?',True); ToolTip="Delete"" CausesValidation="false" />





请尽量帮助我

提前致谢



Please try to help me
Thanks in advance

推荐答案

您是否在加载页面时正确注册了活动? />


Have you registered the event properly on loading of the page ?

<pre lang="xml"><script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptManager1.RegisterAsyncPostBackControl(Button1);
    }
</script>


尝试使用GridViews
Try using GridViews
RowCommand

事件而不是RowDeleting

并将ImageButton的CommandName属性从Delete更改为不同的东西,例如DeleteRecord



按钮上的gridview rowcommand示例 [ ^ ]

event instead of RowDeleting
and change the CommandName property of ImageButton from "Delete" to something different e.g. DeleteRecord

Example of gridview rowcommand on Button Click [^]


if(!IsPostBack)

{


}

缺少
if(!IsPostBack)
{

}
this is missing


这篇关于网格视图删除事件不是火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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