I have a dropdownlist, and when I set AutoPostBack="true", the page keeps refreshing.
any who knows what might be wrong?
<asp:Repeater ID="repFunctionsToAdd" runat="server" OnItemDataBound="repFunctionsToAdd_ItemDataBound">
<ItemTemplate>
<div class="person-section">
<div class="row">
<strong>
<%# Eval("Name") %>
</strong>
<a class="btn-question" href="#">question</a>
<div class="load">
<img src="../images/load<%# Eval("PreProductionLoad") %>.gif" width="40" height="16" alt="image description" />
<img src="../images/load<%# Eval("ProductionLoad") %>.gif" width="40" height="16" alt="image description" />
<img src="../images/load<%# Eval("PostProductionLoad") %>.gif" width="40" height="16" alt="image description" />
</div>
</div>
<div class="row">
<div class="btn01 btn-tilfoj">
<ctrl:Hyperlink ID="hlAddFunction" runat="server" Icon="Plus" Text="Tilføj" />
</div>
<label for="select2">
Tilføj til:</label>
<asp:DropDownList ID="ddlUsers" runat="server" Width="190" OnSelectedIndexChanged="ddlUsers_Sic" AutoPostBack="true" />
</div>
</div>
</ItemTemplate>
</Repeater>
The DropDownList shouldn't be inside the ItemTemplate, as this means it will get "repeated" for each item.
Because the DropDownList has AutoPostBack to true, and one static event handler, every time you select an item, ALL of the items in the dropdown will fire the autopostback event.
So if you have 100 items in your repeater, the AutoPostBack will get fired 100 times for each selected index change event.
Make sense?
Move the DropDownList to outside the repeater, and it should solve your problem.
However, if you MUST have it inside the repeater (if want each item to have specific behaviour), you'll need to wire up the SelectedIndexChanged event on the ItemCreated event:
protected void repFunctionsToAdd_ItemCreated(object sender, RepeaterItemEventArgs e)
{
DropDownList dll = e.Item.FindControl("ddlUsers");
ddl.SelectedIndexChange += ddlUsers_Sic;
}