Updating placeholder during runtime

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • allstar11
    New Member
    • Mar 2010
    • 1

    #1

    Updating placeholder during runtime

    Hi Everyone, here is the problem I am having with placeholder:

    I have a repeater and within that repeater, I have an item template. Now this template is formatted with a couple of tables, but for this question I have removed them to make things easier to read:

    Code:
    <asp:Repeater ID="Repeater1" OnItemDataBound="R1_ItemDataBound" runat="server">
            
       <ItemTemplate>
          <asp:PlaceHolder ID="phAnswers" runat="server"></asp:PlaceHolder>               
       </ItemTemplate>
    </asp:Repeater>
    Then, on the event OnItemDataBound , I create a new placeholder, bind it to the existing on (phAnswers), however the placeholder is not updated with the radiobuttons/textboxs that are created:

    Code:
            Dim rdList As New RadioButtonList
            Dim newRadio As New RadioButton
    
     If (e.Item.ItemType = ListItemType.Item) Or _
                (e.Item.ItemType = ListItemType.AlternatingItem) Then
    
                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.Text = t_MC(x).Value
                        rdList.Controls.Add(newRadio)
    
                    Next
    
         tempPH.Controls.Add(rdList)
    Any ideas why phAnswers is not updated with the new tempPH placeholder?
    Cheers
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Have you tried using a Panel instead of a Placeholder?

    I don't think this is going to work out for you too well because of the way you are using/declaring your dynamic controls.

    Check out this quick overview of how to use dynamic controls in asp.net

    -Frinny

    Comment

    Working...