Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 837589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:09:53+00:00 2026-05-15T05:09:53+00:00

I am working in ASP .net 2.0. I am a learner. I have a

  • 0

I am working in ASP .net 2.0. I am a learner. I have a grid view which has a button in it. Please find the asp mark up below

<form id="form1" runat="server">
<div>
    <asp:GridView ID="myGridView" runat="server">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Button CommandName="AddARowBelow" Text="Add A Row Below"   runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
</div>
</form>

Please find the code behind below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;

namespace GridViewDemo
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable("myTable");
            dt.Columns.Add("col1");
            dt.Columns.Add("col2");
            dt.Columns.Add("col3");
            dt.Rows.Add(1, 2, 3);
            dt.Rows.Add(1, 2, 3);
            dt.Rows.Add(1, 2, 3);
            dt.Rows.Add(1, 2, 3);
            dt.Rows.Add(1, 2, 3);
            myGridView.DataSource = dt;
            myGridView.DataBind();
        }

        protected void myGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {

        }
    }
}

I was thinking that when I click the command button, it would fire the mygridview_rowcommand() but instead it threw an error as follows:

Invalid postback or callback argument. Event validation is enabled using 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.

Can any one let me know on where I am going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:09:54+00:00Added an answer on May 15, 2026 at 5:09 am

    First, try to disable event validation and see what the result is, since that is the obvious problem in your code.

    <%@ Page EnableEventValidation="false" ...
    

    However, if you don’t want to restort to such a hack, do the following:

    After that, delete the OnCommand event from the button’s attributes, and add an OnRowCommand event to the GridView itself.

    Example:

    <asp:GridView OnRowCommand="myGridView_RowCommand">
        ...
    </asp:GridView>
    

    This should be the correct way of handling these commands.
    The button must have a specific CommandName in order for it to work as intended.

    See this page for possible values and more explanation of this issue. There is also a working example on that page, it is worth your time to check it out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with ASP.NET MVC and have a view page with a simple
Working in ASP.NET MVC, I have a view model with an Amount field. The
I am working on asp.net MVC3 application and I have created a layout.cshtml which
I'm working in ASP.NET and have a text box in which I enter First
I am working with ASP.NET doing some client side javascript. I have the following
I am working on an ASP.NET project which is physically located at C:\Projects\MyStuff\WebSite2. When
I'm working on an ASP.NET website which targets desktop browsers. We want to enable
For the last 4 years I have been working as an ASP.NET developer in
I'm currently working on an ASP.NET application, and I have downloaded the Visual Studio
While working with ASP.NET using Visual Studio (2008) I have discomfort issue: source code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.