repeater checkbox oncheckchanged

I have a repeater Control and each item has a checkbox on it. I can't figure out how to use the OnCheckedChange event for this checkbox.

 <asp:Repeater ID="rptImageList" runat="server" OnItemDataBound="rptImages_ItemDataBound" OnItemCommand="rptImages_ItemCommand">
            <asp:Table runat="server" BorderStyle="None" HorizontalAlign="Left" Width="100%" GridLines="Both">
                    <asp:TableCell Width="3%">
                        <asp:CheckBox ID="cbSelect" runat="server" AutoPostBack="true" Checked='<%#((DataBinder.Eval(Container.DataItem,"IsSelected")!=null) && ((bool)DataBinder.Eval(Container.DataItem,"IsSelected")==true)) %>' OnCheckedChanged="cbSelect_CheckedChanged" />

Code Behind

        protected void rptImages_ItemDataBound(object sender, RepeaterItemEventArgs e)
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            var cbSelect = e.Item.FindControl("cbSelect") as CheckBox;                

    protected void cbSelect_CheckedChanged(object sender, EventArgs e)

How can I be able to use the state of the checkbox in the cbSelect_CheckedChanged event? I want it when checked changed to change it's assigned BIT field in the database!


You can created methods to handle checked changes and the sender as CheckBox will send the correct checkbos to your handler method.

private void Checked_Handler(object sender, RoutedEventArgs e)
    HandleChecked(sender as CheckBox);

You can also use the HandleChecked and HandleUnchecked Events

From the docs:

private void HandleCheck(object sender, RoutedEventArgs e)
    CheckBox cb = sender as CheckBox;
    if (cb.Name == "cb1")
        text1.Text = "Two state CheckBox checked.";
        text2.Text = "Three state CheckBox checked.";

private void HandleUnchecked(object sender, RoutedEventArgs e)
    CheckBox cb = sender as CheckBox;
    if (cb.Name == "cb1")
        text1.Text = "Two state CheckBox unchecked.";
        text2.Text = "Three state CheckBox unchecked.";

private void HandleThirdState(object sender, RoutedEventArgs e)
    CheckBox cb = sender as CheckBox;
    text2.Text = "Three state CheckBox indeterminate.";

and the xaml:

<!-- two state CheckBox -->
<CheckBox x:Name="cb1" Content="Two State CheckBox" 
      Checked="HandleCheck" Unchecked="HandleUnchecked" Margin="5" />
<TextBlock x:Name="text1" Margin="5" />

<!-- three state CheckBox -->
<CheckBox x:Name="cb2" Content="Three State CheckBox" 
    IsThreeState="True" Checked="HandleCheck" 
    Indeterminate="HandleThirdState" Unchecked="HandleUnchecked" Margin="5" />
<TextBlock x:Name="text2" Margin="5" />

Need Your Help

Redirect feature phone users to another site

redirect smartphone browser-detection

I have a website that works well on all tablets, mobiles and desktops. However when users access the site via a feature phone like a nokia asha or something similar the site doesn't work well at all.

Android get the Intent when implementing RecognitionListener

java android android-intent

As stated in this answer by Iftah I can get the audio recorded by the Speech Recoginition in android by getting the Uri from the Intent passed to: