Controls disappeared when postback

2 posts, 0 answers
  1. camilla
    camilla avatar
    1 posts
    Member since:
    Sep 2007

    Posted 03 Feb 2010 Link to this post

    I am trying to dynamically create some RadPanelItems according to the user input no. e.g. When user input 3, I will dynamically create 3 RadPanelItems. And in each RadPanelItems will have some textboxes and button for user to use. The controls in each RadPanelItem are the same. But when the use click on the button inside the RadPanelItem. All the runtime created controls disappeared. Is there anything work arround to solve that?

    Hear is my code

        Protected Sub btnTest_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            If txtNoOfInd.Text.Trim IsNot String.Empty Then

            end if
       End Sub

    Sub CreatePanels(ByVal NoOfFrm As Integer)

                For i As Integer = 1 To NoOfInd

                    Dim NoOfPersons As Integer = txtNoOfInd.Text

                    Dim table1 As HtmlTable
                    Dim Row As HtmlTableRow
                    Dim Cell As HtmlTableCell
                    Dim txtName As TextBox
                    Dim lblName As Label
                    Dim btnNext As Button

                    txtName = New TextBox
                    txtName.ID = "txtName" & i.ToString

                    lblName = New Label
                    lblName.ID = "lblName" & i.ToString
                    lblName.AssociatedControlID = "txtName" & i.ToString
                    lblName.Text = "Name:"

                    btnNext = New Button
                    btnNext.ID = "btnNext" & i.ToString
                    btnNext.Text = "Next"

                    table1 = New HtmlTable
                    Row = New HtmlTableRow
                    Cell = New HtmlTableCell


                    Dim newParentItem As RadPanelItem = New RadPanelItem()
                    Dim newChildItem As RadPanelItem = New RadPanelItem()

                    newParentItem.Text = i.ToString
                    If i = 1 Then
                        newParentItem.Expanded = True
                    End If

        End Sub

  2. Yana
    Yana avatar
    4547 posts

    Posted 04 Feb 2010 Link to this post

    Hi Camilla,

    Dynamically added controls to RadPanelBar items are not preserved and should be added on every postback.

    All the best,
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. DevCraft R3 2016 release webinar banner
Back to Top