title: asp:ImageButton in Gridview OnClick event not working
body: <p>I've spent quite a while searching this problem, there are some other similar threads online but none have helped me fix it.</p>
  
  <p>I have a GridView with an ImageButton within it, the imagebutton has an OnClick function but that event is never reached when it is clicked, below is my gridview:</p>
  
  <pre><code>&lt;asp:GridView ID="gridBuildings" runat="server" AutoGenerateColumns="False"
                GridLines="none" ShowFooter="false" ShowHeader="false" 
                Width="100%"&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:ImageButton runat="server" ID="cmdBuy"
                       ImageUrl="~/images/button.jpg" 
                       OnClick="ImageButton_Click"/&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>and here's the code-behind (I've removed the extra content, the response.redirect is never hit when the ImageButton is clicked)</p>
  
  <pre><code>Protected Sub ImageButton_click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
      response.redirect("test.aspx")
      Dim row As GridViewRow = Me.gridBuildings.SelectedRow
      (etc ... )
  End Sub
  </code></pre>
  
  <p>There is a form runat="server" tag in the master page, as well as an asp:UpdatePanel and an asp:AjaxScriptManager I have a feeling the problem might be something to do with a postback but just can't work it out - any help would be appreciated.</p>
  
  <p>Thanks!</p>