Sayantan Das
Sayantan Das

Reputation: 71

Grid view row command showing error

I am getting this error:

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.

This is my code:

protected void GridViewCommandEventHandler(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "view")
    {
        int row_id = Convert.ToInt32(e.CommandArgument);
        var result = (from test in je.jobposting where test.id==row_id select                test).FirstOrDefault();
        Session["id"] = result;
    }
    else
    {
        int row_id = Convert.ToInt32(e.CommandArgument);
        var result = (from test in je.jobposting where test.id==row_id select test).FirstOrDefault();
        je.DeleteObject(result);
        je.SaveChanges();
        Response.Redirect ("");
    }
}

Upvotes: 0

Views: 1156

Answers (1)

AbdulRahman Ansari
AbdulRahman Ansari

Reputation: 3057

set EnableEventValidation property of page in aspx file to false

Upvotes: 1

Related Questions