473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how loop through various labels' text values

hi

i have various labels on my page with ID's label_1, label_2 , label_3 etc.

How can i write a loop that sequentially changes their text values to
values i have in an array eg;.

for (i=0;i<max;i++) {
label_1.text = labelarray[i]
}

then on next 2 loops:
label_2.text=la belarray[i]

and

label_3.text=la belarray[i]

etc.etc.


Nov 18 '05 #1
2 2262
Hi Tony,

You could put the labels in an arraylist and then use the foreach statement
to go through this list. This will look something like this:

ArrayList labellist = new ArrayList()
labellist.add(l abel_1)
labellist.add(l abel_2)
labellist.add(l abel_3)

//Loop throught the list of labels
foreach(Label lbl in labellist)
{
lbl.text = labelarray[i]
}

Or if this affects ALL labels which are on your page you could loop trough
the Page.Controls property

foreach(Label lbl in Page.Controls)
{
lbl.text = labelarray[i]
}

Hope it helps. Cheers,

Gerben.

"tony collier" <me*****@hotmai l.com> wrote in message
news:Xn******** *************** ********@140.99 .99.130...
hi

i have various labels on my page with ID's label_1, label_2 , label_3 etc.

How can i write a loop that sequentially changes their text values to
values i have in an array eg;.

for (i=0;i<max;i++) {
label_1.text = labelarray[i]
}

then on next 2 loops:
label_2.text=la belarray[i]

and

label_3.text=la belarray[i]

etc.etc.

Nov 18 '05 #2
"Gerben van Loon" <no************ *@home.nl> wrote in news:btu7nd$r2t $1
@news2.tilbu1.n b.home.nl:
ArrayList labellist = new ArrayList()
labellist.add(l abel_1)
labellist.add(l abel_2)
labellist.add(l abel_3)


fantastic! thanks a lot.
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3917
by: Dave | last post by:
I have to automate a process that assigns sales leads to sales people. For example: Every day we buy a list of sales leads, it ranges in size from 50 - 100 records. We have a team of sales people that also can range from 5 - 8 people. I need to take the new records and divide them evenly among the sales people.
2
12825
by: chris | last post by:
Hi there, I created a Multidimensional array of labels Label lblMultiArray = new Label { {Label3, LblThuTotal}, {Label4,LblFriTotal} }; Now I would like to compare the values in the array, comparing the text in Label3 and LblThuTotal and the text in Label4 and LblFriTotal.
3
2405
by: lawrencec | last post by:
Hi there, I'm trying to add the values of a number of form fields and to get a result at the end. It must loop and be able to dynamically update the result of calculation. I have attached the code i have so far. Thanks <html> <head>
0
1467
by: Zamael | last post by:
Currently I have a dataset that populates as follows (example data): ID Cycle Drug_Day Name 3 1 1 Initial 3 1 15 Initial 3 2 1 Initial 3 2 15 Initial 3 3 1 Initial 3 3 15 Initial
3
2086
by: peter.meth | last post by:
Hi All, I am making a file manager type of application and am trying to duplicate Windows Explorer's behaviour when copying files; ie, display a second form with the copy files animation. As it is copying files, it should show the file name and folder. For testing purposes I am sleeping for 1 second to simulate a file being copied. My problem is that when I run the code, the labels do not change to reflect the file names until the...
2
1331
by: Jeff | last post by:
....another beginner question - using visual web 2005 with VB I have 20 labels - lbl1 through lbl20 I have a listbox containing values 1 through 20 I need to make label 1 through the selected value of the listbox visible, but the rest of the labels invisible I'm assuming that the best way to do this is with 2 loops in the listbox click event something like:
1
2440
by: Doug_J_W | last post by:
I have a Visual Basic (2005) project that contains around twenty embedded text files as resources. The text files contain two columns of real numbers that are separated by tab deliminator, and are of different lengths (e.g. usually between 25 and 45 rows. The columns in each file have the same length). The text files have been numbered sequentially e.g. cb0, cb1, cb2 and so on. I would like to read the data from each text file into...
3
1825
by: Alex | last post by:
Hi, We're working on what will become a multi-language application, and I wanted to see if this idea is feasable. What we're thinking of doing is creating a table to contain all text of the application and in multiple languages, for example: Col1 - ID Col2 - English Col3 - French
5
1580
by: dp_pearce | last post by:
I have some code that takes data from an Access database and processes it into text files for another application. At the moment, I am using a number of loops that are pretty slow. I am not a hugely experienced python user so I would like to know if I am doing anything particularly wrong or that can be hugely improved through the use of another method. Currently, all of the values that are to be written to file are pulled from the...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.