Reputation: 4692
I have checkbox in the DataList. Now I need to execute a code-behind when the checkbox is ticked. As far as I know the itemcommand in datalist will not triggered when the checkbox is ticked. I even tried to put the onCheckChanged event in the checkbox but it even worse the situation (not just does not trigger the event but also does allow me to tick the checkbox at all).
Does anyone has a solution?
thanks
Upvotes: 0
Views: 1955
Reputation: 12589
I just created a DataList with a CheckBox in it like this:
<asp:DataList ID="Datalist1" runat="server" DataSourceID="Sqldatasource1">
<ItemTemplate>
<asp:CheckBox ID="Checkbox1" Text="text" runat="server" OnCheckedChanged="Checkbox1_CheckedChanged" AutoPostBack="true" />
</ItemTemplate>
</asp:DataList>
and this code-behind
protected void Checkbox1_CheckedChanged(object sender, EventArgs e)
{
}
That allowed me to break into the CheckedChanged event without any problem.
Upvotes: 1
Reputation: 50728
Are you setting AutoPostBack="true" on the <asp:CheckBox control? It might fire the ItemCOmmand event, otherwise, you would have to tap into the CheckChanged event for the control on ItemCreated event.
Upvotes: 0