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.Checked then
'Do your stuff
Exit For
End If
End If
Next
"Sakharam Phapale" <sp******@annetsite.com> wrote in message
news:OJ*************@TK2MSFTNGP10.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.Checked then
'Do your stuff
Exit For
End If
End If
Next
Hopes this will help
Sakharam Phapale
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.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(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"), String)
oObjCheckBox.Text =
CType(dsCustomer.Tables(0).Rows(iCount).Item("LocN ame"), String)
pnlLocs.Controls.Add(oObjCheckBox)
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.Checked) Then
'do some stuff
Else