I have a situation where I have a page in ASP.NET. In this page I have a RadioButtonList, which contains 5 solutions to a question. The RadioButtonList is feeded by an object, which has these solutions.
I have a timer, which runs every second, to update loads of graphical controls. Everything works, BESIDES the RadioButtonList selection.
This is what happends:
When I select an item in the RadioButtonList and the timer tick, the selectedIndex of the RadioButtonLIst value is 0.
This means it selects the FIRST item in the list. However, IF I click an item, which has a "Yes" value in it (the value field can either have "No" or "Yes", it will stay at this item.
First of all, I have NO idea why the timer re-select my RadioButtonList selection, as any other Page_Load event does nothing. And even if that makes sense, I have no idea why it just re-selects SOME of the answers..
I have the following HTML code:
<asp:Timer ID="AssignmentTimer" runat="server" Interval="1000">
</asp:Timer>
<asp:UpdatePanel ID="FightUpdatePnl" runat="server" UpdateMode="Always" ChildrenAsTriggers="True">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="AssignmentTimer" EventName="Tick"/>
</Triggers>
<ContentTemplate>
<asp:Panel ID="AssignmentDiv" runat="server" CssClass="FightDiv">
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
I have the following code behind:
protected void Page_Load(object sender, EventArgs e)
{
SetupPage();
}
private void SetupPage()
{
RadioButtonList list = new RadioButtonList();
list.DataSource = question.PossibleSolution;
list.DataTextField = "Content";
list.DataValueField = "IsAnswer";
list.DataBind();
AssignmentDiv.Controls.Add(list);
}
So, to summarize, my problem is...
When the timer ticks, the RadioButtonList re-select item 0. This is however not consistent, and sometimes it doesn't re-select. I'd rather it didn't re-select at all! :)