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.