There is a nested repeater in my work. I'm responsible to add asp:checkbox on every underneath repeater item, so that we can control each item by checkbox.
The markup code is:
<ItemTemplate>
<li class="<%# GetCategoryClass(Container.DataItem) %> cl-li">
<asp:CheckBox runat="server" ID="checkBox" AutoPostBack="true" OnCheckedChanged="CheckedChanged" />
<a class="cl-a excludeLink" visible='<%# GetCategoryClass(Container.DataItem) == "DISPLAYED" %>' href="<%# GetExcludeCategoryCommand(Container.DataItem) %>" runat="server" id="butExclude">x</a>
<a class="cl-a" href="<%# GetCategoryCommand(Container.DataItem) %>" runat="server" id="butCategory"><%# GetCategoryTitle(Container.DataItem, true) %></a>
</li>
</ItemTemplate>
The c# code is:
protected void CheckedChanged(object obj, EventArgs e)
{
// some works
}
I start to work on this problem and find the CheckedChanged function isn't fired via debugging. But, when I add a line in
if(IsPostBack){
CheckedChanged(sender, e); //add
}
It works and goes into CheckedChanged function when I debug. I have read many articles, none of them say I need to add that line in IsPostBack block. Is there anyone can show me the principle of that?