Results 1 to 4 of 4

Thread: [RESOLVED] Resolve Control name on the fly?

  1. #1

    Thread Starter
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Resolved [RESOLVED] Resolve Control name on the fly?

    Don't think that the best title...

    Does anyone know how to resolve object names on the fly

    e.g. I have 6 controls called

    mybox1
    mybox2
    mybox3
    ...


    when the form is submitted I want to look though them creating a list

    VB Code:
    1. Dim mystring as string
    2.  
    3. for i = 1 to 6
    4.   mystring += mybox+i.tostring.trim + ","
    5. next
    6.  
    7. 'Save myString to DB

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Resolve Control name on the fly?

    Is this a clue?

    VB Code:
    1. Dim txtTemp As New TextBox
    2.  
    3. For i As Integer = 0 to 6
    4. mystring &= CType(Page.FindControl("mybox" & i.ToString()), TextBox) & ","
    5. Next i

  3. #3
    Fanatic Member d2005's Avatar
    Join Date
    Aug 2005
    Location
    ireland
    Posts
    620

    Re: Resolve Control name on the fly?

    does it have anything to do with execute scalar,
    i always seem to ned to use that for values

    im a newbie and i know this prob wont help u sry
    it works 60% of the time, all the time.

  4. #4

    Thread Starter
    Fanatic Member aconybeare's Avatar
    Join Date
    Oct 2001
    Location
    UK
    Posts
    772

    Re: Resolve Control name on the fly?

    Mendhak,

    Thanks for the tip

    This seems to work

    VB Code:
    1. Dim myStr As String = vbNullString
    2. Dim txtTemp As New TextBox
    3.  
    4. For i As Integer = 1 To 3
    5.     txtTemp = CType(Page.FindControl("txtName" & i.ToString()), TextBox)
    6.     myStr += txtTemp.Text.ToString.Trim & ","
    7. Next i
    8.  
    9. Response.Write("Returned Vals: " & myStr)

    I've tried giving you kudos on a few occasions but I keep getting told I need to spread my love around first.

    Much obliged anyway

    Cheers Al

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