Results 1 to 2 of 2

Thread: Help caputuring properties in dynamic controls on postback

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2004
    Posts
    3

    Help caputuring properties in dynamic controls on postback

    I declared a placeholder on a web form and I add dropdownlists to it dynamically (dont know how many at any given time). How do I get the results out on the next postback? Am I missing an event to trap the values with? Every time I try (like in the post buttons click event, I am missing the selected values.)

    HERE IS THE GENERATING CODE

    For Each item As System.Web.UI.WebControls.ListItem In CheckBoxList1.Items
    If item.Selected Then
    Results1 += item.Value & ";"
    Dim Name As New Label
    Name.Text = item.Text & "<br>"
    Dim CatLink As New DropDownList
    CatLink.Items.Add("1")
    CatLink.Items.Add("2")
    CatLink.Items.Add("3")
    CatLink.Items.Add("4")
    CatLink.Items.Add("5")
    CatLink.ID = item.Value
    Me.PlaceHolderQ2.Controls.Add(Name)
    End IF
    Next item

    HERE I AM TRYING TO READ THE VALUES


    Dim myresults As String
    For Each cont As Control In Me.PlaceHolderQ2.Controls
    Try
    'Dim drop As New DropDownList
    myresults += CType(cont, DropDownList).SelectedValue & ";"
    Catch ex As Exception

    End Try

    Next

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    In what event are you running the code you posted...

    1) Are you using Page_Load? And are you checking for a IsPostback, so you don't recreate the controls and lose their events evertime the page posts back.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width