Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted

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 ;)

Posted

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.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...