OnCheckedChanged event not firing in GridView at all

Adam picture Adam · Aug 17, 2009 · Viewed 27.6k times · Source

I have a GridView with an asp CheckBox in a TemplateField. The TemplateField is defined as follows:

<asp:TemplateField HeaderText="HeaderName">
    <ItemTemplate>
        <asp:CheckBox ID="checkBoxId" runat="server" OnCheckedChanged="MyCheckChangedMethod" AutoPostBack="true"/>
    </ItemTemplate>
</asp:TemplateField>

When I run my web project with a breakpoint inside MyCheckChangedMethod and click the checkbox nothing happens. The breakpoint is not hit. My Visual Studio debugger is running.

Additionally, I have AutoEventWireup = True in my page defnition so I don't have to manually hook up the event. I have never had a problem doing it this way before. I have a button on the same page setup the exact same way with a click event and the breakpoint gets hit fine in that.

Any ideas?

Answer

royalnight102 picture royalnight102 · Dec 16, 2009

You need to add AutoPostback = True in asp:CheckBox tag.