Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2005
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    getting dynamically created controls

    Okay, so I'm making a page that queries a database and for every row that matches the criteria it creates a set of controls that allow for editing that row. Unfortunately I can't remember how to refer to dynamically created controls. The controls in each set follow a formula that allows me to get the id of each other control in the set, but I can't remember how to get dynamically created controls, that way when they hit the edit button for that set it will look at the other controls for that set and edit the row accordingly.

    Code:
    Code:
    enddatum = placeDyEnd.SelectedItem.Value
    What do I put instead of the bolded part? With some languages it would be something like: [stringofid].SelectedItem.Value. I already tried that and it didn't know what I was talking about. I also tried () instead of [], but that didn't work either.

    Any help would be appreciated.

    Brett Bretterson

  • #2
    New Coder
    Join Date
    Aug 2005
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found it. You use the FindControl() function. If you have to do this please note that it doesn't like to do things like FindControl("foobar").SelectedValue. It will say that SelectedValue isn't a property of System.Web.UI.Control. A way around this is to put the found control into a dropdownlist and then get the selected value. Like this:

    Code:
    Dim myDDList1 As DropDownList = FindControl("foo")
    If myDDList1.SelectedValue = "bar" Then
    'whatever
    End if


  •  

    Posting Permissions

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