ASP.NET UpdatePanel > Get selected value from checbox list outside of panel

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-03-29T02:56:17Z Indexed on 2010/03/29 3:13 UTC
Read the original article Hit count: 348

Filed under:
|
|

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>

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about updatepanel