ASP.NET: GridView pageEventValidation problem
<p>In the following code:</p>

<p>EnquiryList.ascx:</p>

<pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="EnquiryList.ascx.cs" Inherits="includes_EnquiryList"%&gt;
&lt;div class="EnquiryForm" runat="server"&gt;

    &lt;asp:GridView ID="gridMain" 
        runat="server" 
        PageSize="20"
        Width="390"
        GridLines="None" 
        CssClass="gridview" 
        AllowPaging="True"
        AllowSorting="True" 
        CellPadding="0" 
        AutoGenerateColumns="False"
        OnPageIndexChanging="gridMain_PageIndexChanging"
        OnRowCommand="gridMain_RowCommand"
        DataSourceID="ldsGridMain"&gt;

        &lt;Columns&gt;

             &lt;asp:TemplateField&gt;
                &lt;ItemTemplate&gt;

                    &lt;%# Eval("Id") %&gt;
                    &lt;asp:Button Text="Bekräfta" ID="apa" runat="server" CommandArgument='&lt;%# Eval("Id") %&gt;' CommandName="Buy" class="enquiryBtn"/&gt;

                &lt;/ItemTemplate&gt;
             &lt;/asp:TemplateField&gt;


        &lt;/Columns&gt;

    &lt;/asp:GridView&gt;

    &lt;asp:LinqDataSource ID="ldsGridMain" runat="server" OnSelecting="ldsGridMain_Selecting" OnSelected="ldsGridMain_Selected"/&gt;

&lt;/div&gt;
</code></pre>

<p>EnquiryList.ascx.cs:  </p>

<pre><code>using System;
using System.Web.UI.WebControls;
using System.Web.UI;
using Offerta.Presentation;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public partial class includes_EnquiryList : System.Web.UI.UserControl
{

    protected Boolean IsAuthenticatedSupplier { get; set; }

    protected Boolean ShowSimilarEnquiriesLink { get; set; }

    protected int totalRows = 0;

    protected LinqDataSourceSelectEventArgs selectArgs;

    protected Supplier supplier;

    protected IQueryable&lt;Enquiry&gt; enquiries;

    protected string errorMessage;

    protected void Page_Load(object sender, EventArgs e)
    {
        IsAuthenticatedSupplier = false;
        Auth auth = new Auth();
        if (auth.IsAuthenticated)
        {
            IsAuthenticatedSupplier = auth.ClientTypeId == ClientMethods.CLIENT_TYPE_SUPPLIER;
            if (IsAuthenticatedSupplier)
            {
                supplier = (Supplier)auth.Client;
            }
        }
    }


    public void Bind(IQueryable&lt;Enquiry&gt; enquiries)
    {
        this.enquiries = enquiries;
        gridMain.DataBind();
    }

    protected void ldsGridMain_Selecting(object sender, LinqDataSourceSelectEventArgs e)
    {
        selectArgs = e;
        e.Result = (new EnquiryListController()).List(enquiries, supplier);
    }

    protected void ldsGridMain_Selected(object sender, LinqDataSourceStatusEventArgs e)
    {
        totalRows = selectArgs.Arguments.TotalRowCount;
    }

    protected void gridMain_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gridMain.PageIndex = e.NewPageIndex;
        gridMain.DataBind();
    }

    protected void gridMain_RowCommand(object sender, GridViewCommandEventArgs e)
    {
    //never gets here?
    switch (e.CommandName.ToString())
        {
            case "Buy":
                PurchaseEnquiry(e.CommandArgument.ToString());
                break;
        }
    }

    protected void PurchaseEnquiry(string enquiryId)
    {
        try
        {
            Enquiry enquiry = EnquiryMethods.Get(new Guid(enquiryId));
            Order order = OrderMethods.Purchase(supplier, enquiry);
            Response.Redirect((new UrlFactory()).GetSupplierEnquiryMessageUrl(order.Id.ToString()), true);
        }
        catch (Exception e)
        {
            errorMessage = e.Message;        
        }
    }

}
</code></pre>

<p>In SupplierInbox.aspx.cs (SupplierInbox.aspx basically only contains a EnquiryList and html)</p>

<pre><code>using System;

public partial class SupplierInbox : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {
        (new Auth()).RequireClientOfType(ClientMethods.CLIENT_TYPE_SUPPLIER);
        ucEnquiryList.Bind(EnquiryMethods.BuildQuery(new EnquiryQuery()));
    }

}
</code></pre>

<p>When pressing the Button in the GridView I keep getting </p>

<blockquote>
  <p>Invalid postback or callback argument.
  Event validation is enabled using
  
  in configuration or &lt;%@ 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.</p>
</blockquote>

<p>If I disable EventValidation, nothing happens when I press the button, i.e. gridMain_RowCommand is never called. What am I doing wrong?</p>
