Click here to Skip to main content
12,510,189 members (54,228 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# C#4.0

I was trying an application on ASP.NET 4.0 using DataGrid with 2 data columns and 2 columns bearing "Edit/Update/Cancel" and "Add/Delete" button. The grid is populating nicely but as I am clicking on Add or Edit button, I am getting the following error:
Server Error in '/' Application.
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.


I tried many forums and problem solving sites but could not find a proper satisfying solution in the form of implementation. If anyone could help me out of this problem. it would be great.

the page is designed as under:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="DataGridApp.WebForm2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head  runat="server">
    <form id="form1"  method="post"  runat="server">
        <asp:DataGrid ID="dg1" runat="server" AutoGenerateColumns="False" 
            BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" Width="500px" 
            Font-Bold="False" Font-Italic="False" Font-Overline="False" 
            Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Center" 
            oncancelcommand="dg1_Cancel" ondeletecommand="dg1_Delete" 
            oneditcommand="dg1_Edit" onitemcommand="dg1_ItemCommand" 
            onitemdatabound="dg1_DataBound" onupdatecommand="dg1_Update" ShowFooter="True">
                <asp:BoundColumn HeaderText="S.No" ReadOnly="True">
                    <itemstyle font-bold="False" font-italic="False" font-overline="False">
                        Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Center" 
                        VerticalAlign="Middle" />
Thanks in advance

Posted 30-Nov-12 1:53am
Updated 30-Nov-12 2:09am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 30 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100