Question

I have a page that contains a Repeater, which contains server control elements, within an UpdatePanel and while all other controls behave normally, the Drop Down control causes a full postback every time.

<asp:Repeater ID="rpt" runat="server">
    <ItemTemplate>
        <asp:SomeWorkingControl ID="swc" runat="server" />
        <asp:DropDownList ID="ddl" runat="server" OnSelectedIndexChanged="ddl_SelectedIndexChanged" AutoPostBack="true">
            <asp:ListItem Text="0" Value="0" />
            <asp:ListItem Text="1" Value="1" />
        </asp:DropDownList>
    </ItemTemplate>
</asp:Repeater>

This is vaugely what my code looks like, the DropDownList control is actually in a UserControl, but the theory is the same.

If I apply an event to SomeWorkingControl then there is an Ajax postback and all is fine.

However, the event associated with the DropDownList causes a full postback! I know usually you would set an Async trigger for the DropDown, but since it is created in a repeater (and therefore I can not know how many there will be) so I don't really see how that could work.

Is there anybody who has experienced this before and knows a workaround perhaps?

Was it helpful?

Solution

Try to change this line:

<asp:DropDownList ID="ddl" runat="server" OnSelectedIndexChanged="ddl_SelectedIndexChanged" AutoPostBack="true">

for:

<asp:DropDownList ID="ddl" runat="server" OnSelectedIndexChanged="ddl_SelectedIndexChanged" AutoPostBack="true" ClientIDMode="AutoID">

Recently I had the same problem and I found out that the ClientIDMode can solve it.

Please have a look here: asp.net ClientIDMode Changes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top