473,769 Members | 3,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(strCon trolName & intCount).Value = 1

Thanks.

Nov 19 '05 #1
2 1170
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***@villages oft.com> wrote in message
news:11******** *************@z 14g2000cwz.goog legroups.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(strCon trolName & 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
21812
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
3024
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 access to the methods and properties from the Page_Load, no problem there. But as soon as I want access to the user control from another procedure on the same page, I get the next error message: "Object reference not set to an instance of an...
0
942
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 and server form. 3. In WebForm1.aspx.cs, I created a WebUserControl1 and attached it to panel by: WebUserControl1 oCtl = new WebUserControl1();
7
3195
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 -- UC/ ----- Classic/
1
1489
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") = 10 (you can assume the grid is binded to this dataset table) I get an error telling me row 0 does not exist. I'm assuming I need to use a New command to add rows in a
2
1583
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 some specail effect as the user press 'enter' in the 3rd column, how can i know the user press 'enter' in the 3rd column ?? Thanks in advance From Agnes
3
1307
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 context menu also appear on my main menu. Do I have to use the Designer to add them to both (that is, do I have to input the data twice.)
2
29661
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.", What is IBindingList and how would i go about using it. Here are my code private void dataGridView1_ColumnHeaderMouseClick(object sender,
4
2113
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 on button2, the same lighting effect occurs, the the image is changed to image2 and so on. Now when the movie loads, I want to programmically fire off the actions of button1, button2, button3, button4, button5 in sequence. Pseudocode: On...
0
9589
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
9423
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
10216
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
8873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
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
3
2815
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.