>I want to create an ArrayList of names ("Tony","Robin","Johnson") on
> one page and then on another page I want to populate a TextBox field
> with those names from the Arraylist. How do I populate the TextBox?
Enumerate the list, forming a string from the names (using whatever
delimiters, if any, you desire of course), and then set the text of the
TextBox to that string.
Ciaran O''Donnell - 09 Nov 2006 12:54 GMT
The best way to enumerate the list is:
string[] names = (string[])list.ToArray(typeof(string));
textbox1.Text = string.Join("\r\n",names);
Ciaran O'Donnell
> >I want to create an ArrayList of names ("Tony","Robin","Johnson") on
> > one page and then on another page I want to populate a TextBox field
[quoted text clipped - 3 lines]
> delimiters, if any, you desire of course), and then set the text of the
> TextBox to that string.
Ciaran O''Donnell - 09 Nov 2006 12:56 GMT
Or
object[] names = list.ToArray();
string.Concat(names);
this might be better because the arraylist doesnt copy the internal array
for this but the string.concat does a bit more work. This would use less
memory though.
Ciaran O'Donnell
> >I want to create an ArrayList of names ("Tony","Robin","Johnson") on
> > one page and then on another page I want to populate a TextBox field
[quoted text clipped - 3 lines]
> delimiters, if any, you desire of course), and then set the text of the
> TextBox to that string.
Ciaran O''Donnell - 09 Nov 2006 12:59 GMT
Scrub this one, the ToArray() does copy the array so the other one is better.
> Or
> object[] names = list.ToArray();
[quoted text clipped - 13 lines]
> > delimiters, if any, you desire of course), and then set the text of the
> > TextBox to that string.
C#Schroeder - 09 Nov 2006 15:18 GMT
Thanks to everyone for the help. It works
> Scrub this one, the ToArray() does copy the array so the other one is better.
>
[quoted text clipped - 15 lines]
> > > delimiters, if any, you desire of course), and then set the text of the
> > > TextBox to that string.