473,804 Members | 4,066 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic controls

Joe
quick question,
Im using VB.NET
Im creating a checkbox dynamically then I stick it on a panel. I give each
one a unique id example: "chkLONDON"
Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chk" +
CType(dsCustome r.Tables(0).Row s(iCount).Item( "LocName"), String)

oObjCheckBox.Te xt = CType(dsCustome r.Tables(0).Row s(iCount).Item( "LocName"),
String)

pnlLocs.Control s.Add(oObjCheck Box)

My problem now is, how do I see if that value is checked or not from my
code. When I push my submit button I want to check if its cheked or not. I
tried the following but it didn't work.

Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chkLONDON"

If (oObjCheckBox.C hecked) Then

'do some stuff

Else

Nov 21 '05 #1
4 2102
Hello Joe,

To use the dynamically created controls you have to get the reference of the
control object.
Here you can do that by iterating through the controls in Panel.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox
If myCheckBox.ID=" Test" and myCheckBox. myCheckBox.Chec ked then
'Do your stuff
Exit For
End If
End If
Next

Hopes this will help

Sakharam Phapale
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:03******** *************** ***********@mic rosoft.com...
quick question,
Im using VB.NET
Im creating a checkbox dynamically then I stick it on a panel. I give each one a unique id example: "chkLONDON"
Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chk" +
CType(dsCustome r.Tables(0).Row s(iCount).Item( "LocName"), String)

oObjCheckBox.Te xt = CType(dsCustome r.Tables(0).Row s(iCount).Item( "LocName"), String)

pnlLocs.Control s.Add(oObjCheck Box)

My problem now is, how do I see if that value is checked or not from my
code. When I push my submit button I want to check if its cheked or not. I tried the following but it didn't work.

Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chkLONDON"

If (oObjCheckBox.C hecked) Then

'do some stuff

Else

Nov 21 '05 #2
Hi Joe,

I missed one statement so corrected here.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox

------------ myCheckBox =
Type(myControl, CheckBox) -----------------------------------

If myCheckBox.ID=" Test" and myCheckBox. myCheckBox.Chec ked then
'Do your stuff
Exit For
End If
End If
Next
"Sakharam Phapale" <sp******@annet site.com> wrote in message
news:OJ******** *****@TK2MSFTNG P10.phx.gbl...
Hello Joe,

To use the dynamically created controls you have to get the reference of the control object.
Here you can do that by iterating through the controls in Panel.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox

myCheckBox = CType(myControl ,CheckBox)

If myCheckBox.ID=" Test" and myCheckBox. myCheckBox.Chec ked then
'Do your stuff
Exit For
End If
End If
Next

Hopes this will help

Sakharam Phapale
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:03******** *************** ***********@mic rosoft.com...
quick question,
Im using VB.NET
Im creating a checkbox dynamically then I stick it on a panel. I give each
one a unique id example: "chkLONDON"
Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chk" +
CType(dsCustome r.Tables(0).Row s(iCount).Item( "LocName"), String)

oObjCheckBox.Te xt =

CType(dsCustome r.Tables(0).Row s(iCount).Item( "LocName"),
String)

pnlLocs.Control s.Add(oObjCheck Box)

My problem now is, how do I see if that value is checked or not from my
code. When I push my submit button I want to check if its cheked or

not. I
tried the following but it didn't work.

Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chkLONDON"

If (oObjCheckBox.C hecked) Then

'do some stuff

Else


Nov 21 '05 #3
Hello Joe,

To use the dynamically created controls you have to get the reference of the
control object.
Here you can do that by iterating through the controls in Panel.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox
If myCheckBox.ID=" Test" and myCheckBox. myCheckBox.Chec ked then
'Do your stuff
Exit For
End If
End If
Next

Hopes this will help

Sakharam Phapale
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:03******** *************** ***********@mic rosoft.com...
quick question,
Im using VB.NET
Im creating a checkbox dynamically then I stick it on a panel. I give each one a unique id example: "chkLONDON"
Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chk" +
CType(dsCustome r.Tables(0).Row s(iCount).Item( "LocName"), String)

oObjCheckBox.Te xt = CType(dsCustome r.Tables(0).Row s(iCount).Item( "LocName"), String)

pnlLocs.Control s.Add(oObjCheck Box)

My problem now is, how do I see if that value is checked or not from my
code. When I push my submit button I want to check if its cheked or not. I tried the following but it didn't work.

Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chkLONDON"

If (oObjCheckBox.C hecked) Then

'do some stuff

Else

Nov 21 '05 #4
Hi Joe,

I missed one statement so corrected here.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox

------------ myCheckBox =
Type(myControl, CheckBox) -----------------------------------

If myCheckBox.ID=" Test" and myCheckBox. myCheckBox.Chec ked then
'Do your stuff
Exit For
End If
End If
Next
"Sakharam Phapale" <sp******@annet site.com> wrote in message
news:OJ******** *****@TK2MSFTNG P10.phx.gbl...
Hello Joe,

To use the dynamically created controls you have to get the reference of the control object.
Here you can do that by iterating through the controls in Panel.

Dim myControl as Control
For each myControl in Panel.Controls
If TypeOf (myControl) Is CheckBox Then
Dim myCheckBox as CheckBox

myCheckBox = CType(myControl ,CheckBox)

If myCheckBox.ID=" Test" and myCheckBox. myCheckBox.Chec ked then
'Do your stuff
Exit For
End If
End If
Next

Hopes this will help

Sakharam Phapale
"Joe" <Jo*@discussion s.microsoft.com > wrote in message
news:03******** *************** ***********@mic rosoft.com...
quick question,
Im using VB.NET
Im creating a checkbox dynamically then I stick it on a panel. I give each
one a unique id example: "chkLONDON"
Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chk" +
CType(dsCustome r.Tables(0).Row s(iCount).Item( "LocName"), String)

oObjCheckBox.Te xt =

CType(dsCustome r.Tables(0).Row s(iCount).Item( "LocName"),
String)

pnlLocs.Control s.Add(oObjCheck Box)

My problem now is, how do I see if that value is checked or not from my
code. When I push my submit button I want to check if its cheked or

not. I
tried the following but it didn't work.

Dim oObjCheckBox As CheckBox = New CheckBox()

oObjCheckBox.ID = "chkLONDON"

If (oObjCheckBox.C hecked) Then

'do some stuff

Else


Nov 21 '05 #5

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

Similar topics

1
6325
by: Will | last post by:
Hi all. I'm learning VB.Net and am developing a WinForms app. I'm trying to make an app that I will use to scan in one or more than on image. I want to use a tabbed interface to hold each image. Here's the code I'm using for testing purposes. I've got the code in the form's load event, but I think I'd have the same problems no matter where the code existed. Right now, the form has an empty tab control, everthing else is dynamic. <code>
2
5323
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted user controls. Worse I'm trying to add dynamic user controls from within a repeater loop (looping through attributes)... I bind to a function in the code behind and pass in the attribute. <asp:repeater id="rAttributes" Runat="server">
3
3989
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which step you're on. This all works fine, but I ran into some trouble when I started creating controls dynamically in my code-behind file. Each panel contains a table which is filled with various radio buttons, text fields and the such which are...
0
1347
by: pbb | last post by:
I have a web page on which I dynamically create controls based on the selection a user makes from a dropdownlist (this ddl is not dynamic). Depending on the user's selection, the controls could be any combination of textboxes, ddls, popup calendars, etc. The properties of the dynamic controls are stored in a SQL database so that my program can know what type of control to render and what items to put in the ddl etc. My problem is that I...
1
2206
by: Diffident | last post by:
Hello All, I am trying to add dynamic controls onto my page and here is how I am doing that. I have a page which has a button called as "AddMoreControls" and in this button's event handler I am creating controls dynamically and adding them to a panel on the page. For example, if the button is clicked once, the page is posted back and the controls are added properly. However, if I click the "AddMoreControls" for the second time the...
9
3632
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have to create the dynamic controls in the OnInit stage of the lifecycle. Since data from static controls is not yet available in the OnInit stage I can't know what dynamic control I have to create.
0
5296
by: Eniac | last post by:
Hi, I've been working on a custom user control that needs to be modified and the validation is causing me headaches. The control used to generate a table of 4 rows x 7 columns to display all the days in the week with dates and textboxes to fill in some data. row 1: question
1
4665
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be removed. I used viewstate to keep my value for postback, I want by changing selectedvalue of...
0
3504
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by...
2
5038
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation is this, I have a page which uses multiple postbacks to generate a list of dynamic text boxes with appropriate labels. However, when I do the final postback to enter the values in the dynamic textboxes into the database the values seem to become...
0
9589
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
10593
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
10340
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
10329
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5527
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...
0
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
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
3000
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.