Dropdowns in repeater full page postback

254 views Asked by At

I have run into an issue I am having a hard time explaining.

I am working on improving an existing solution and I am seeing behavior with my dropdowns that I was not expecting. It seems they are always doing a full page postback even though they are set to be async. They are inside of a repeater.

Here is my repeater in my update panel.

 <asp:UpdatePanel runat="server" ID="upnlPartSelector" ChildrenAsTriggers="true" UpdateMode="Always" Visible="false">
<ContentTemplate>
    <div class="product-page">
        <div class="row">

            <asp:Repeater runat="server" ID="rptFilterCategories" OnItemDataBound="RptCategories_ItemDataBound" OnItemCreated="rptFilterCategories_ItemCreated">
                <HeaderTemplate>
                    <div class="filter-selection">
                </HeaderTemplate>
                <ItemTemplate>
                    <div class="title">
                        <%# Eval("CategoryName") %>
                    </div>
                    <div class="select">
                        <asp:DropDownList CssClass="form-control" runat="server" ID="ddlFilterItems" AutoPostBack="true" DataTextField="Display" DataValueField="Value" OnSelectedIndexChanged="ddlFilterItems_SelectedIndexChanged"/>
                    </div>
                </ItemTemplate>
                <FooterTemplate>
                    </div>
                </FooterTemplate>
            </asp:Repeater>
    </div>
</ContentTemplate>

I am registering the dropdowns as async triggers on the repeaters OnItemCreated method.

 protected void rptFilterCategories_ItemCreated(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            var control = e.Item.FindControl("ddlFilterItems");
            ScriptManager.GetCurrent(Page).RegisterAsyncPostBackControl(control);
        }
    }

And yet still they are doing a full page postback instead of just updating the panel. Do I need to set the repeater as a trigger for the update panel? Or specifically say which update panel the Async Postback Control connects with?

1

There are 1 answers

1
Rick S On

Have you tried adding the trigger in html to see if that makes it work correctly? And temporarily comment out the RegisterAsyncPostBackControl in the code behind.

</ContentTemplate>
<Triggers> 
    <asp:AsyncPostBackTrigger ControlID="ddlFilterItems" EventName="SelectedIndexChanged" /> 
</Triggers>