David Hall
David Hall

Reputation: 113

Checkbox OnCheckedChanged event not firing

I have a datagrid that is populated through user input, and in that grid I have a checkbox that should remove the row from the datagrid if checked. I have set the EnableViewState to true and false with no results. It appears that if the checkbox is clicked, the event does not fire. Debugging never gets to the event. Can anyone point me? Here's the markup:

     <asp:TemplateColumn HeaderText="Remove">
          <ItemTemplate>
               <asp:checkbox ID="chkSelection" runat="server" AutoPostBack="True"  Checked="false" OnCheckChanged="EPACheck_Clicked"/>
          </ItemTemplate>
          <ItemStyle HorizontalAlign="Center" Width="50px" />

And here's the code behind for the event:

Protected Sub EPACheck_Clicked(ByVal sender As Object, ByVal e As EventArgs)

    Dim ckbx As CheckBox = CType(sender, CheckBox)
    Dim dgItem As DataGridItem = CType(ckbx.NamingContainer, DataGridItem)
    Dim rcDelete As String = dgItem.ItemIndex
    CType(Session("mytable"), DataTable).Rows.RemoveAt(Convert.ToInt32(rcDelete))
    BindgrdEPA()

End Sub

Upvotes: 1

Views: 2361

Answers (2)

CoolBreeze
CoolBreeze

Reputation: 381

The reason OnCheckedChanged wasn't firing for me was because I disabled IE8's Protected Mode.

Once I enabled Protected Mode OnCheckedChanged worked.

Previously, I had disabled Protected Mode to test a cookie problem with one of our web applications. I didn't re-enable Protected Mode when I finished that task.

To re-enable Protected Mode I did this:

  1. Clicked on Tools\Internet Options.
  2. Clicked on Security tab.
  3. Clicked on Reset all zones to default level. I suppose I could have clicked "Enable Protected Mode" checkbox.

Upvotes: 0

ic3man7019
ic3man7019

Reputation: 711

Your method doesn't handle the event. Try the below snippet.

Protected Sub EPACheck_Clicked(ByVal sender As Object, ByVal e As EventArgs) 
  Handles chkSelection.CheckedChanged

Upvotes: 1

Related Questions