How to retrieve data from Dynamic Textboxes?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Victor

    #1

    How to retrieve data from Dynamic Textboxes?

    I have dynamically created n number of text boxes in a form like txtQL(1),
    txtQL(2) , ...txtQL(n)
    How can I retrieve the values in a loop? I'm confused as to how to approach
    this! Please help.

    I get the error "Referenced object has a value of 'Nothing'". as indicated in
    the code below:

    For Each c In Controls
    If i < maxRow Then[color=blue]
    >Error txtQLLink(i) = c.FindControl(" txtQLLink(" + i & ")")[/color]
    txtQLUrl(i) = c.FindControl(" txtQlUrl(" + i & ")")
    If txtQLLink(i).Te xt <> "" Then
    textQLHtml = textQLHtml & txtQLUrl(i).Tex t & txtQLLink(i).Te xt
    strQL = strQL & txtQLLink(i).Te xt & "," & txtQLUrl(i).Tex t
    i += 1
    End If
    End If
    Next


    Thanks for your time.

  • Victor

    #2
    RE: How to retrieve data from Dynamic Textboxes?

    OK. It works now.

    For Each c In Controls
    If i < maxRow Then
    Dim strTextBoxId = "txtQLLink" + "(" + i.ToString + ")"
    txtQLLink(i) = c.FindControl(s trTextBoxId)
    txtQLUrl(i) = c.FindControl(" txtQlUrl" + "(" + i.ToString + ")")
    If txtQLLink(i).Te xt <> "" Then
    strQL = strQL & txtQLLink(i).Te xt & "," & txtQLUrl(i).Tex t
    If i < maxRow Then
    strQL = strQL & ","
    End If
    i += 1
    End If
    End If
    Next

    Comment

    Working...