Dynamically adding strings?

ttkalec1

Newcomer
Joined
Feb 26, 2005
Messages
19
Hi, I have an (I think) easy question.

I have a situation where i have an array of strings like
Dim Names as string()

and this array doesn't always have the same number of strings in it.

My problem is that i have to print that strings on to my aspx page but I obviously can't use label controls on my aspx form for this, cause I don't know how much strings will I have, so I can't populate my labels.
I need to print these names in a list like this:

Peter
Bob
Michael

So, what control to use for this or how to print these names one below the other?
 
I found out the solution to my problem and It's really simple :D
I need to have one label control and just put a text like this in it:

label1.text = "Some text <br /> tekst in new line"

and that solves my problem ;)
 
You could also use an ArrayList object and the ListView object to display.

[csharp]
ArrayList strings = new ArrayList(3);

strings.Add("MyString1");
strings.Add("MyString2");
strings.Add("MyString3");

{ListBox}.DataSource = strings;
{ListBox}.DataBind();
[/csharp]

This way, you will have the correct values displayed regardless of how many strings you have.
 
Back
Top