日期:2014-05-17  浏览次数:20393 次

gridview行删除事件
前台代码,只写出了删除按钮的一列代码
HTML code
<asp:GridView ID="GridView1" runat="server"  CellPadding="4"
                EnableModelValidation="True" ForeColor="#333333" GridLines="None" 
                Visible="false" onrowcommand="GridView1_RowCommand">
<AlternatingRowStyle BackColor="White" />
<Columns>
                    <asp:TemplateField HeaderText="删除操作">
                        <ItemTemplate>
                            <asp:Button ID="delete" runat="server" Text="删除" CommandName="del" CommandArgument='<%#Eval("ID") %>' />
                        </ItemTemplate>
                        <ItemStyle Wrap="True" />
                        <HeaderStyle Wrap="False" />
                    </asp:TemplateField>
</Columns>
</asp:GridView>


后台代码
C# code
 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "del")//此处加断点
            {
                int id = int.Parse(e.CommandArgument.ToString());
                FrameWork.BusinessFacade.AttachmentDelete(id);
                BindGrid();
            }
}




问题是,这个gridview在一个页面运行可以,把代码移到另一个页面就出错了,调试时直接报错误,不命中断点
访问路径:/Manager/Module/FrameWork/SRMManage/SRM_Notice/Manager.aspx?CMD=Edit&IDX=47<br>System.Web thrown System.ArgumentException<br />回发或回调参数无效。在配置中使用 <pages enableEventValidation="true"/> 或在页面中使用 <%@ Page EnableEventValidation="true" %> 启用了事件验证。出于安全目的,此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。如果数据有效并且是预期的,则使用 ClientScriptManager.RegisterForEventValidation 方法来注册回发或回调数据以进行验证。<br /> 在 System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument)<br /> 在 System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument)<br /> 在 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)<br /> 在 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)<br /> 在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)<br /> 在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)<br /> 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

------解决方案--------------------
仅供参考http://www.cnblogs.com/yuxuetaoxp/archive/2010/01/01/1637293.html
------解决方案--------------------
估计是拖控件生成的一些隐藏代码没拷贝过去。
你在另外一个页面重新拖一个试试。比如说xxx.aspx.designer.cs中的一些代码。