473,386 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Indexing a control

In VB6 I could form an array of labels and reference them by index number.
In a C# ASP.net 2 application I need to reference Label33 through Label64
programmatically. I'd like to use a for loop
for (i = 33; i < 65; i += 1)
Any suggestions on how to accomplish this would be appreciated. Code
samples are welcomed. I'd like the correct syntax.
Thanks in advance for your help,
Jim
Feb 25 '07 #1
2 1060
You probably want to use FindControl:
http://msdn2.microsoft.com/en-us/lib...ndcontrol.aspx

Feb 25 '07 #2
You can create your own array of labels and initialize it in Form_Load event
handler, or right in the constructor after all the labels are created.

Something like:

private Label[] m_arrLabels;

private void Form_Load( object sender, EventArgs e )
{
m_arrLabels = new Label[3] { Label1, Label2, Label3 };
for( int i = 0; i < m_arrLabels.Length; i ++ )
m_arrLabels[i].Text = "label " + i;
}
"Jim McGivney" <mc****@no-spam.sbcglobal.netwrote in message
news:uW**************@TK2MSFTNGP03.phx.gbl...
In VB6 I could form an array of labels and reference them by index number.
In a C# ASP.net 2 application I need to reference Label33 through Label64
programmatically. I'd like to use a for loop
for (i = 33; i < 65; i += 1)
Any suggestions on how to accomplish this would be appreciated. Code
samples are welcomed. I'd like the correct syntax.
Thanks in advance for your help,
Jim

Feb 26 '07 #3

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

Similar topics

21
by: Hilde Roth | last post by:
This may have been asked before but I can't find it. If I have a rectangular list of lists, say, l = ,,], is there a handy syntax for retrieving the ith item of every sublist? I know about for i...
15
by: Jay | last post by:
Hello all. I've recently transferred our web sites from a Windows2000 server to a Windows2003 server. The transfer went almost flawless until I noticed that our search function isn't working...
108
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would...
0
by: sonu | last post by:
I have created a list like... row1item1 row1item2 row1item3 row2item1 row2item2 row2item3 row3item1 row3item2 row3item3 ......... ..... ...... can we indexing in List control in...
7
by: Ryan | last post by:
I have a bit of a problem with regards an indexing strategy. Well, basically there is no indexing strategy on a set of data I have at work. Now, I didn't create the design as I would have allowed...
0
by: Chung Leong | last post by:
Here's a short tutorial on how to the OLE-DB extension to access Windows Indexing Service. Impress your office-mates with a powerful full-text search feature on your intranet. It's easier than you...
3
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and...
4
by: Emin | last post by:
Dear Experts, How much slower is dict indexing vs. list indexing (or indexing into a numpy array)? I realize that looking up a value in a dict should be constant time, but does anyone have a...
4
by: pratimapaudel | last post by:
I have tables in my database, it's sql server 2005. I heard some of them have indexing and some of them doesnot have indexing. If i want to check whether it has indexing or not how do i do? ...
2
by: =?Utf-8?B?SmVycnkgQw==?= | last post by:
I have a server 2008 IIS 7.0 with indexing service installed. I have created the catalog and have a test page using these posts:...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...

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.