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
Hi.

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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title></title>
</head>
<body>
    <form id="form1"  method="post"  runat="server">
    <div>
    
        <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">
            <columns>
                <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

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

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