I have hierarchy which i need to bind to checkbox for parent and checkboxlist for 1 level children.
Somehow i cannot get to checkboxes(CheckBoxParent_CheckedChanged),checkboxlist’s (CheckBoxListChildren_SelectedIndexChanged) select events, without UpdatePanel as well.
Working on it for 4 hours without any result, why i can’t enter event when i check some checkbox ?
What am I doing wrong ?
Thanks
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ListViewCategories.DataSource = CategoryManager.ListHierarchy();
ListViewCategories.DataBind();
}
}
protected void CheckBoxParent_CheckedChanged(object sender, EventArgs e)
{
if (((CheckBox)sender).Checked)
{
}
else
{
}
}
protected void CheckBoxListChildren_SelectedIndexChanged(object sender, EventArgs e)
{
if (((CheckBoxList)sender).SelectedItem != null)
{
}
else
{
}
}
<asp:UpdatePanel ID="UpdatePanelCategories" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<ContentTemplate>
<asp:ListView ID="ListViewCategories" runat="server">
<LayoutTemplate>
<div id="itemPlaceholder" runat="server"></div>
</LayoutTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBoxParent" runat="server" Text='<%# Eval("Key.Name") %>' OnCheckedChanged="CheckBoxParent_CheckedChanged" /><br />
<asp:CheckBoxList ID="CheckBoxListChildren" runat="server" OnSelectedIndexChanged="CheckBoxListChildren_SelectedIndexChanged" RepeatDirection="Horizontal" DataSource='<%# DataBinder.Eval(Container.DataItem, "Value") %>' DataTextField="Name"></asp:CheckBoxList><br /><br />
</ItemTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
Put the “AutoPostBack” of CheckBox to true.