Question Indirect Textbox reference

ArchAngel

New member
Joined
Oct 22, 2008
Messages
3
Programming Experience
Beginner
Is there a way to reference a group of TEXTBOX as if they were an array?

Right now I’m using TextBox0, TextBox1, TextBox2, TextBox3…
And I want to populate it with Data(0), Data(1), Data(2), Data(3)…

I want to try to do something like:

Dim x As Integer = 0
Do While (x < max)
(Textbox + x).text = Data(x)
Loop
 
give this a try

VB.NET:
 Do While intcnt < max
            DirectCast(Me.Controls.Find("TextBox" & intcnt, True)(0), TextBox).Text = Data(intcnt)
        Loop

I am not sure this is the best method, but it should still work.
 
But the following did work:

VB.NET:
 Do While intcnt < max
       DirectCast(Me.FindControl("TextBox" & intcnt), TextBox).Text = Data(intcnt)
 Loop


Thanks
 
Thread moved to ASP.NET Web Forms forum. Please post in most appropriate forum.
 
Back
Top