title: Repeater with Buttons doesn't fire OnItemCommand even when DataBind doesn't happen when IsPostBack is true
body: <p>I've got an image button in a Repeater, which is in a User Control, and I can't get the OnItemCommand event to fire when I click it. It always gives the error: "... Invalid postback or callback argument.  Event validation is enabled using ..."</p>
  
  <p>When I change the image button to a link button, it doesn't give me the error, but it still doesn't fire the OnItemCommand function.</p>
  
  <p>I found some other relevant answers (such as <a href="https://stackoverflow.com/questions/411491/how-to-process-events-from-buttons-inside-repeaters-and-whats-this-enableevent">How to process events from Buttons inside Repeaters? And what&#39;s this EnableEventValidation thing?</a>) but they all say, "Make sure you're data-binding your repeater inside of a if(!Page.IsPostBack) block." I have done that, but it didn't make a difference.</p>
  
  <p>Here's the markup for the repeater:</p>
  
  <pre><code>   &lt;asp:Repeater ID="rptExpenses" OnItemDataBound="rptExpenses_ItemDataBound" OnItemCommand="Button_Command" runat="server" &gt;
     &lt;ItemTemplate&gt;
        &lt;asp:ImageButton ID="ibDelete" ImageUrl="~/Images/delete.png" CommandName="Delete" runat="server" /&gt;
     &lt;/ItemTemplate&gt;
     &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>Here's some exerpts from the code-behind</p>
  
  <pre><code>  protected void Page_Load(object sender, EventArgs e) {
       if (!IsPostBack) {
          rptExpenses.DataSource = ExpenseIds;
          rptExpenses.DataBind();
       }
    }
  
    protected void rptExpenses_ItemDataBound(object sender, RepeaterItemEventArgs e) {
       if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) {
          var ibDelete = (ImageButton)e.Item.FindControl("ibDelete");
          ibDelete.CommandArgument = e.Item.DataItem.ToString();
       }
    }
  
    protected void Button_Command(object sender, EventArgs e) {
       var btn = (IButtonControl)sender;
       switch (btn.CommandName) {
          case "Delete":
             //delete it
             break;
       }
    }
  </code></pre>