On Wed, 12 Nov 2003 02:58:41 -0800, josema <je****************@ocu.org>
wrote:
Hi...
I have an array of elements that has dinamic size,
sometimes has 5 elements, sometimes 3 etc...
I would like to create a WebForm with as <input type=text>
as elements i have in this array
What is the way to make this, cause if i use a loop i dont
know how i can instanciate the class with another name...
For instance
for (int i=0;i<array.lenght;i++)
{
TextBox mytextbox=new TextBox();
}
the problem with this is that: mytextbox is instanciate so
many times and i dont know how i can give another name to
the control in each round in the loop.
I suppose that its not the correct way, make this.. no?
Thanks in advance...
Josema.
You don't have to worry about what name each texbox have as they don't
care. But you do need to keep track of the references to them. In your
loop, you will create a new TextBox but it will disappear instantly since
you don't store the reference for it anywhere.
I'm not sure what you are trying to accomplish, but a way to create as
many textboxes as there are items in the array list you can do something
like
ArrayList textboxList = new ArrayList();
for( int i = 0; i < array.Length; i++ )
{
TextBox namemdoesnotmatter = new TextBox();
textboxList.Add(namedoesnotmatter);
}
textboxList now holds all TextBox references for later use.
--
Using M2, Opera's revolutionary e-mail client:
http://www.opera.com/m2/