dynamically change variable name and assign a value

asp.net Ottawa, Canada
  • 14 years ago

    Hello - bit a beginner here

    Let's say I have 20 asp labels on a page (names label1 to label20) and I want to set their values at run time.  Is it possible to go through a list of all the labels without explicitly writing each one?   Maybe a loop that goes through label & i (where i is a value from 1 to 20) and then within the loop set the values for label & i = "text value".    

    I used to code in VB6 a long time ago and I remember their being something about a "for each object in ObjectType" type of loop.

    Any help would be appreciated!

    Thanks,

    HyperHyper

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems.” - Jamie Zawinski