I have an ImageButton in a GridView.
<asp:GridView ID="ItemGridView" runat="server" DataKeyNames="Id"
OnRowDataBound="ItemGridView_RowDataBound" AllowPaging="True"
AllowSorting="True" EnableSortingAndPagingCallbacks="True"
AutoGenerateEditButton="False" AutoGenerateDeleteButton="false"
DataSourceID="ItemDataSource" EnableViewState="true" >
....
<asp:TemplateField ShowHeader="False" ItemStyle-Width="40px">
<ItemTemplate>
<asp:ImageButton ID="btnDelete" SkinID="btnDelete"
runat="server" CausesValidation="false"
OnClick="btnDeleteAccountItem_Click"
OnClientClick="javascript:return confirm('Are you sure?');" />
</ItemTemplate>
</asp:TemplateField>
and a corresponding handler for the delete button event
protected void btnDeleteAccountItem_Click(object sender, EventArgs e) {
ImageButton btnDel = sender as ImageButton;
GridViewRow row = (GridViewRow)btnDel.NamingContainer;
....
}
I am using this very same construct in many places and it works fine. I have one gridview now, though, where it does not, and I am hoping to get some ideas for how to track down the problem.
When I click the button, the client-side event fires and the alert box is displayed, then the post-back fires and I can hit a break point in the Page_Load
method. So the client-side wiring of the button events seems to work. However, the event is not handled and the method btnDeleteAccountItem_Click does not get called.
This is a complex page and I cannot post all the code. What can I do to narrow down potential causes?