473,408 Members | 1,743 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,408 software developers and data experts.

How do I Programmically Reference ASP Control

How do I "build" the name of an ASP control in the VB Code behind? I
would like to cycle through several comboboxes using a loop.
(cboReport1, cboReport2, cboReport3, etc.)

ie. in MS-Access I can use the following code to reference a combobox
named cboReport6 and set it's value to 1:

strForm = MyForm
strControlName = "cboReport"
intCount = 6

Forms(strForm).Controls(strControlName & intCount).Value = 1

Thanks.

Nov 19 '05 #1
2 1154
Use the FindControl() method of your Page/Control instance. This control
takes a string parameter that represents the ID of the control (the ID you
give like id="cboReport1" runat="server"). You get a base Control object if
it was found. Then you simply has to cast it to the right type (which you
should know which type it is), but ideally you would also verify that the
instance reference you got via FindControls() is of the type you expect.

Emil

"kentg" <ke***@villagesoft.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
How do I "build" the name of an ASP control in the VB Code behind? I
would like to cycle through several comboboxes using a loop.
(cboReport1, cboReport2, cboReport3, etc.)

ie. in MS-Access I can use the following code to reference a combobox
named cboReport6 and set it's value to 1:

strForm = MyForm
strControlName = "cboReport"
intCount = 6

Forms(strForm).Controls(strControlName & intCount).Value = 1

Thanks.

Nov 19 '05 #2
Thanks Emil.

I appreciate you taking the time to answer my question.

Kent.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #3

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

Similar topics

6
by: Lloyd | last post by:
How do you make a textbox enabled or disabled ??? i have tried Textbox.disable or enable but the controls apparently dont have this property programmically ???
1
by: Martine | last post by:
Hi there! I have a problem with programmatically adding user controls to my mobile webforms. If I load my usercontrol programmatically (in the Page_Load), the object is instantiated, I have...
0
by: Calvin Lai | last post by:
Hi all, I have a problem in creating web user control *programatically*. Problem as follows: 1. WebUserControl1 contains a server side table named Table1 2. WebForm1 contain a server panel...
7
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb --...
1
by: Sebastian Santacroe | last post by:
Hello, I've got a datagrid with two columns and no data. I want to add data programmically (from DB). When I try to use sintax like: dataset.Tables("Department").Rows(0).Item("Percentage Used")...
2
by: Agnes | last post by:
I set my datagrid's datasource programmically . However , as the form load, I found that every column width is the same, Question 1) How can i adjust it programmically ??? Question 2) I need to do...
3
by: Franky | last post by:
I'm trying to learn about the MenuStrip and the ContextStrip. I use Google and get an unbelievable number of hits but can't seem to find out the answer to one question. All the items on my...
2
by: tee | last post by:
Hi, How do i sort datagridview programmically, current i have the following code but i keep get the error saying "DataGridView control must be bound to an IBindingList object to be sorted.", ...
4
by: cdawson2000 | last post by:
Hello Gurus, I have a movie that is composed of a picture and 5 buttons below it. When the user clicks button1, a lighting effect occurs, then the image is changed to image1. When the user clicks...
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
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...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.