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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:034D3DB1-12DD-48E0-A37F-(E-Mail Removed)...
> > 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("LocName"), String)
> >
> > oObjCheckBox.Text =
> CType(dsCustomer.Tables(0).Rows(iCount).Item("LocName"),
> > 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
> >
>
>
|