Hi,
I have a listing in an UpdatePanel
I have some filters for that list in the form a checkboxList control.
The checkboxList is created dynamically on page load
During the Ajax update (postback), the checkbox list is not populated form the viewstate, so I cannot get the listing to filter.
Note: If I put the checkbox list items directly in the markup, it all works, just not if the listing is populated on-postback.
protected override void OnLoad(EventArgs e)
{
if (!Page.IsPostBack)
{
foreach (var p in global.Product)
CheckListManufacurer.Items.Add(new ListItem(p, p));
}
base.OnLoad(e);
}
<form id="ProductListForm" runat="server">
<asp:ScriptManager ID="ScriptManager" runat="server" EnablePartialRendering="true"></asp:ScriptManager>
<asp:CheckBoxList ID="CheckListManufacurer" runat="server" EnableViewState="true">
<asp:ListItem Value="" Text="(All)"></asp:ListItem>
</asp:CheckBoxList>
<asp:Button id="btnTestAjax" runat="server" Text="Test" />
<asp:UpdatePanel ID="ProductsPanel" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnTestAjax" />
<asp:AsyncPostBackTrigger ControlID="CheckListManufacurer" />
</Triggers>
<ContentTemplate>
<sr:ProductList ID="Products" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</form>