Creating/Handling events for controls when added during runtime.
Posted
by AllStar11
on Stack Overflow
See other posts from Stack Overflow
or by AllStar11
Published on 2010-03-11T18:45:51Z
Indexed on
2010/03/11
18:49 UTC
Read the original article
Hit count: 280
I am using a Repeater which contains a placeholder. The placeholder is bound to my database and each ItemTemplate contains 1-6 radiobuttons depending on what the database returns. What I need to do is somehow keep track of which one of the radiobuttons is checked for each question so I can write the user's answers to the database when they complete the test, any ideas??
<asp:Repeater ID="Repeater1" OnItemDataBound="R1_ItemDataBound" runat="server">
<ItemTemplate>
<asp:PlaceHolder ID="phAnswers" runat="server">
</asp:PlaceHolder>
</ItemTemplate>
</asp:Repeater>
Sub R1_ItemDataBound(ByVal Sender As Object, ByVal e As RepeaterItemEventArgs)
Dim tempPH As PlaceHolder
tempPH = e.Item.FindControl("phAnswers")
For x As Integer = 0 To (t_MC.Count - 1)
newRadio = New RadioButton
newRadio.ID = "Answer" + x.ToString
newRadio.GroupName = "Answer" + tempQuestion.ID.ToString
newRadio.Text = t_MC(x).Value
newRadio.Width = 800
tempPH.Controls.Add(newRadio)
© Stack Overflow or respective owner